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

« back to all changes in this revision

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

  • Committer: Matt Giuca
  • Date: 2009-12-01 04:27:58 UTC
  • mfrom: (1164.2.46 sphinx-docs)
  • Revision ID: matt.giuca@gmail.com-20091201042758-wuxd9bdec00c283i
Merged sphinx-docs branch. This adds Sphinx documentation for the entire IVLE system (for system administrators and developers), and removes all of our random old document files (all either irrelevant, or moved into the Sphinx docs nicely). Currently incomplete, but ready to merge.

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()