~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-11 09:09:53 UTC
  • Revision ID: grantw@unimelb.edu.au-20100211090953-592dk5jruwdg1qrq
Declare appropriate tabs on the rest of the views.

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