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

« back to all changes in this revision

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

  • Committer: Matt Giuca
  • Date: 2010-02-25 06:32:57 UTC
  • mto: This revision was merged to the branch mainline in revision 1731.
  • Revision ID: matt.giuca@gmail.com-20100225063257-9cr77e15z049u3v4
ProjectSet page: Added 'Add a new project' button here.

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
import genshi.template
27
27
 
28
28
from ivle.webapp.base.views import BaseView
 
29
from ivle.webapp.base.xhtml import GenshiLoaderMixin
29
30
from ivle.webapp.errors import BadRequest, MethodNotAllowed, Unauthorized
30
31
 
31
32
class RESTView(BaseView):
55
56
        if not hasattr(op, '_rest_api_permission'):
56
57
            raise Unauthorized()
57
58
 
58
 
        if op._rest_api_permission not in self.get_permissions(req.user):
 
59
        if (op._rest_api_permission not in
 
60
            self.get_permissions(req.user, req.config)):
59
61
            raise Unauthorized()
60
62
    
61
63
    def convert_bool(self, value):
148
150
            req.write("\n")
149
151
 
150
152
 
151
 
class XHTMLRESTView(JSONRESTView):
 
153
class XHTMLRESTView(GenshiLoaderMixin, JSONRESTView):
152
154
    """A special type of RESTView which takes enhances the standard JSON
153
155
    with genshi XHTML functions.
154
156
    
163
165
 
164
166
        rest_template = os.path.join(os.path.dirname(
165
167
                inspect.getmodule(self).__file__), self.template)
166
 
        loader = genshi.template.TemplateLoader(".", auto_reload=True)
167
 
        tmpl = loader.load(rest_template)
 
168
        tmpl = self._loader.load(rest_template)
168
169
 
169
170
        return tmpl.generate(self.ctx).render('xhtml', doctype='xhtml')
170
171