~azzar1/unity/add-show-desktop-key

« back to all changes in this revision

Viewing changes to ivle/webapp/base/overlays.py

  • Committer: William Grant
  • Date: 2010-02-25 07:34:50 UTC
  • Revision ID: grantw@unimelb.edu.au-20100225073450-zcl8ev5hlyhbszeu
Activate the Storm C extensions if possible. Moar speed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
 
23
23
import genshi
24
24
 
 
25
from ivle.webapp.base.xhtml import GenshiLoaderMixin
 
26
 
 
27
 
25
28
class BaseOverlay(object):
26
29
    """Abstract base class for all overlays."""
27
30
    plugin_scripts = {}
32
35
 
33
36
    def render(self, req):
34
37
        raise NotImplementedError()
35
 
        
36
 
class XHTMLOverlay(BaseOverlay):
 
38
 
 
39
 
 
40
class XHTMLOverlay(GenshiLoaderMixin, BaseOverlay):
37
41
    """Abstract base class for XHTML overlays.
38
 
    
 
42
 
39
43
    An overlay which provides a base class for overlays which need to return 
40
44
    XHTML. It is expected that apps which use this overlay will be written using
41
45
    Genshi templates.
42
46
    """
43
 
    
 
47
 
44
48
    template = 'template.html'
45
 
    
 
49
 
46
50
    def render(self, req):
47
51
        """Renders an XML stream from the template for this overlay."""
48
52
        ctx = genshi.template.Context()
49
53
        # This is where the sub-class is actually called
50
54
        self.populate(req, ctx)
51
 
        
 
55
 
52
56
        # Renders out the template.
53
57
        template_path = os.path.join(os.path.dirname(
54
58
                        inspect.getmodule(self).__file__), self.template)
55
 
        loader = genshi.template.TemplateLoader(".", auto_reload=True)
56
 
        tmpl = loader.load(template_path)
 
59
        tmpl = self._loader.load(template_path)
57
60
        return tmpl.generate(ctx)
58
 
        
 
61
 
59
62
    def populate(self, req, ctx):
60
63
        raise NotImplementedError()