~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-04-24 14:29:12 UTC
  • mto: This revision was merged to the branch mainline in revision 1196.
  • Revision ID: matt.giuca@gmail.com-20090424142912-bgkaglhv1ct4vi87
ivle.worksheet.utils: Can now calculate exercise and worksheet marks as of a
    particular date (optional argument).
ivle-marks: Added --cutoff argument which allows the user to display the marks
    as of a given date. (This allows you to get the marks at a particular
    cut-off date, since students may continue working past this date; the
    marks should not count).

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