~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: 2010-03-22 06:05:32 UTC
  • Revision ID: matt.giuca@gmail.com-20100322060532-5365361xrx9mh32v
Changed database.py get_svn_url to take a req; include the req.user.login in the Subversion URL. This allows you to check out repositories without separately supplying the IVLE URL (as Subversion won't ask for a username by default). Also removed --username= from the lecturer project view, as it's redundant now. This fixes Launchpad bug #543936.

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