Esempio n. 1
0
    def __init__(self, req, cfg, repServer = None, db=None, session=None,
            authToken=None, reposShim=None):
        self.req = req
        self.cfg = cfg
        self.db = db
        self.reposShim = reposShim

        # always send html-strict; xhtml FTL
        # The default behavior of kid changed between 0.9.1 and 0.9.6
        # in 0.9.1 html-strict produced upper case tags and HTML-strict did not
        # exist. in 0.9.6 HTML-strict produces upper case tags and html-strict
        # produces lower case tags. we want upper case tags.
        if 'HTML-strict' in kid.output_methods:
            self.output = 'HTML-strict'
        else:
            self.output = 'html-strict'
        self.content_type = 'text/html; charset=utf-8'
        self.response = self.responseFactory(content_type=self.content_type)

        self.fields = req.params.mixed()
        self.basePath = normPath(req.script_name)
        if session is None:
            session = {}
        self.session = session
        self.authToken = authToken

        self.siteHandler = SiteHandler()
        self.adminHandler = AdminHandler()
        self.errorHandler = ErrorHandler()
Esempio n. 2
0
    def handle(self, context):
        self.__dict__.update(**context)

        path = normPath(context['cmd'])
        cmd = path.split('/')[1]

        if not cmd:
            self._redirectOldLinks()
        try:
            method = self.__getattribute__(cmd)
        except AttributeError:
            raise web_exc.HTTPNotFound()

        if not callable(method):
            raise web_exc.HTTPNotFound()

        return method
Esempio n. 3
0
    def handle(self, context):
        self.__dict__.update(**context)
        if not self.auth.admin:
            raise web_exc.HTTPForbidden()

        path = normPath(context['cmd'])
        cmd = path.split('/')[1]

        if not cmd:
            return self._frontPage
        try:
            method = self.__getattribute__(cmd)
        except AttributeError:
            raise web_exc.HTTPNotFound()

        if not callable(method):
            raise web_exc.HTTPNotFound()

        return method