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

« back to all changes in this revision

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

  • Committer: William Grant
  • Date: 2009-07-05 03:49:31 UTC
  • mto: (1294.4.2 ui-the-third)
  • mto: This revision was merged to the branch mainline in revision 1353.
  • Revision ID: grantw@unimelb.edu.au-20090705034931-e41r97axkoxeitw6
Move i.w.tutorial traversal stuff into i.w.tutorial.traversal.

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
from ivle.webapp.base.views import BaseView
29
29
from ivle.webapp.base.plugins import ViewPlugin, OverlayPlugin
30
30
from ivle.webapp.errors import HTTPError, Unauthorized
31
 
from ivle.webapp.publisher import NoPath
32
 
from ivle.webapp.breadcrumbs import Breadcrumber
33
31
 
34
32
class XHTMLView(BaseView):
35
33
    """
39
37
    """
40
38
 
41
39
    template = 'template.html'
 
40
 
 
41
    plugin_scripts = {}
 
42
    plugin_styles = {}
 
43
    scripts_init = []
 
44
 
42
45
    allow_overlays = True
43
 
 
44
 
    def __init__(self, *args, **kwargs):
45
 
        super(XHTMLView, self).__init__(*args, **kwargs)
46
 
 
47
 
        self.overlay_blacklist = []
48
 
 
49
 
        self.plugin_scripts = {}
50
 
        self.plugin_styles = {}
51
 
        self.scripts_init = []
52
 
 
53
 
        self.extra_breadcrumbs = []
54
 
        self.overlay_blacklist = []
55
 
 
56
 
    def get_context_ancestry(self, req):
57
 
        return req.router.get_ancestors(self.context)
 
46
    overlay_blacklist = []
58
47
 
59
48
    def filter(self, stream, ctx):
60
49
        return stream
103
92
        ctx['scripts_init'] = self.scripts_init + overlay_bits[3]
104
93
        ctx['app_template'] = app
105
94
        ctx['title_img'] = media_url(req, CorePlugin,
106
 
                                     "images/chrome/root-breadcrumb.png")
107
 
        try:
108
 
            ctx['ancestry'] = self.get_context_ancestry(req)
109
 
        except NoPath:
110
 
            ctx['ancestry'] = []
111
 
 
112
 
        # Allow the view to add its own fake breadcrumbs.
113
 
        ctx['extra_breadcrumbs'] = self.extra_breadcrumbs
114
 
 
115
 
        ctx['crumb'] = Breadcrumber(req).crumb
 
95
                                     "images/chrome/title.png")
116
96
        self.populate_headings(req, ctx)
117
97
        tmpl = loader.load(os.path.join(os.path.dirname(__file__), 
118
98
                                                        'ivle-headings.html'))
209
189
class XHTMLErrorView(XHTMLView):
210
190
    template = 'xhtmlerror.html'
211
191
 
212
 
    def __init__(self, req, context, lastobj):
213
 
        super(XHTMLErrorView, self).__init__(req, context)
214
 
        self.lastobj = lastobj
215
 
 
216
 
    def get_context_ancestry(self, req):
217
 
        return req.router.get_ancestors(self.lastobj)
218
 
 
219
192
    def populate(self, req, ctx):
220
193
        ctx['req'] = req
221
194
        ctx['exception'] = self.context
223
196
class XHTMLUnauthorizedView(XHTMLErrorView):
224
197
    template = 'xhtmlunauthorized.html'
225
198
 
226
 
    def __init__(self, req, exception, lastobj):
227
 
        super(XHTMLUnauthorizedView, self).__init__(req, exception, lastobj)
 
199
    def __init__(self, req, exception):
 
200
        super(XHTMLUnauthorizedView, self).__init__(req, exception)
228
201
 
229
202
        if req.user is None:
230
203
            # Not logged in. Redirect to login page.