Exemplo n.º 1
0
    def __before__(self, action, **env):
        try:
            BaseController.__before__(self, action, **env)

            self._ngds_deployment()
        except (sqlalchemy.exc.ProgrammingError,
                sqlalchemy.exc.OperationalError), e:
            # postgres and sqlite errors for missing tables
            msg = str(e)
            if ('relation' in msg and 'does not exist' in msg) or \
                    ('no such table' in msg):
                # table missing, major database problem
                abort(503, _('This site is currently off-line. Database is not initialised.'))
            else:
                raise
Exemplo n.º 2
0
 def __before__(self, action, **env):
     try:
         BaseController.__before__(self, action, **env)
     except NotAuthorized:
         abort(401, _('Not authorized to see this page'))
     except (sqlalchemy.exc.ProgrammingError,
             sqlalchemy.exc.OperationalError), e:
         # postgres and sqlite errors for missing tables
         msg = str(e)
         if ('relation' in msg and 'does not exist' in msg) or \
                ('no such table' in msg) :
             # table missing, major database problem
             abort(503, _('This site is currently off-line. Database is not initialised.'))
             # TODO: send an email to the admin person (#1285)
         else:
             raise
Exemplo n.º 3
0
    def __call__(self, environ, start_response):
        # we need to intercept and fix the api version
        # as it will have a "/" at the start
        routes_dict = environ["pylons.routes_dict"]
        api_version = routes_dict.get("ver")
        if api_version:
            api_version = api_version[1:]
            routes_dict["ver"] = api_version

        self._identify_user()
        try:
            context = {"model": model, "user": c.user or c.author}
            check_access("site_read", context)
        except NotAuthorized:
            response_msg = self._finish(403, _("Not authorized to see this page"))
            # Call start_response manually instead of the parent __call__
            # because we want to end the request instead of continuing.
            response_msg = response_msg.encode("utf8")
            body = "%i %s" % (response.status_int, response_msg)
            start_response(body, response.headers.items())
            return [response_msg]

        # avoid status_code_redirect intercepting error responses
        environ["pylons.status_code_redirect"] = True
        return BaseController.__call__(self, environ, start_response)
Exemplo n.º 4
0
    def __call__(self, environ, start_response):
        # we need to intercept and fix the api version
        # as it will have a "/" at the start
        routes_dict = environ['pylons.routes_dict']
        api_version = routes_dict.get('ver')
        if api_version:
            api_version = api_version[1:]
            routes_dict['ver'] = api_version

        self._identify_user()
        try:
            context = {'model': model, 'user': c.user or c.author}
            check_access('site_read', context)
        except NotAuthorized:
            response_msg = self._finish(403,
                                        _('Not authorized to see this page'))
            # Call start_response manually instead of the parent __call__
            # because we want to end the request instead of continuing.
            response_msg = response_msg.encode('utf8')
            body = '%i %s' % (response.status_int, response_msg)
            start_response(body, response.headers.items())
            return [response_msg]

        # avoid status_code_redirect intercepting error responses
        environ['pylons.status_code_redirect'] = True
        return BaseController.__call__(self, environ, start_response)
Exemplo n.º 5
0
    def __before__(self, action, **env):
        try:
            BaseController.__before__(self, action, **env)

            self._ngds_deployment()
        except (sqlalchemy.exc.ProgrammingError,
                sqlalchemy.exc.OperationalError), e:
            # postgres and sqlite errors for missing tables
            msg = str(e)
            if ('relation' in msg and 'does not exist' in msg) or \
                    ('no such table' in msg):
                # table missing, major database problem
                abort(
                    503,
                    _('This site is currently off-line. Database is not initialised.'
                      ))
            else:
                raise
Exemplo n.º 6
0
 def __before__(self, action, **env):
     try:
         BaseController.__before__(self, action, **env)
     except NotAuthorized:
         abort(401, _('Not authorized to see this page'))
     except (sqlalchemy.exc.ProgrammingError,
             sqlalchemy.exc.OperationalError), e:
         # postgres and sqlite errors for missing tables
         msg = str(e)
         if ('relation' in msg and 'does not exist' in msg) or \
                ('no such table' in msg) :
             # table missing, major database problem
             abort(
                 503,
                 _('This site is currently off-line. Database is not initialised.'
                   ))
             # TODO: send an email to the admin person (#1285)
         else:
             raise
Exemplo n.º 7
0
 def __call__(self, environ, start_response):
     self._identify_user()
     if not self.authorizer.am_authorized(c, model.Action.SITE_READ, model.System):
         response_msg = self._finish(403, _('Not authorized to see this page'))
         # Call start_response manually instead of the parent __call__
         # because we want to end the request instead of continuing.
         response_msg = response_msg.encode('utf8')
         body = '%i %s' % (response.status_int, response_msg)
         start_response(body, response.headers.items())
         return [response_msg]
     else:
         # avoid status_code_redirect intercepting error responses
         environ['pylons.status_code_redirect'] = True
         return BaseController.__call__(self, environ, start_response)
Exemplo n.º 8
0
 def __call__(self, environ, start_response):
     self._identify_user()
     if not self.authorizer.am_authorized(c, model.Action.SITE_READ,
                                          model.System):
         response_msg = self._finish(403,
                                     _('Not authorized to see this page'))
         # Call start_response manually instead of the parent __call__
         # because we want to end the request instead of continuing.
         response_msg = response_msg.encode('utf8')
         body = '%i %s' % (response.status_int, response_msg)
         start_response(body, response.headers.items())
         return [response_msg]
     else:
         # avoid status_code_redirect intercepting error responses
         environ['pylons.status_code_redirect'] = True
         return BaseController.__call__(self, environ, start_response)
Exemplo n.º 9
0
    def __call__(self, environ, start_response):
        self._identify_user()
        try:
            context = {'model':model,'user': c.user or c.author}
            check_access('site_read',context)
        except NotAuthorized:
            response_msg = self._finish(403, _('Not authorized to see this page'))
            # Call start_response manually instead of the parent __call__
            # because we want to end the request instead of continuing.
            response_msg = response_msg.encode('utf8')
            body = '%i %s' % (response.status_int, response_msg)
            start_response(body, response.headers.items())
            return [response_msg]

        # avoid status_code_redirect intercepting error responses
        environ['pylons.status_code_redirect'] = True
        return BaseController.__call__(self, environ, start_response)
Exemplo n.º 10
0
 def __init__(self):
     BaseController.__init__(self)
     self.extensions = PluginImplementations(IGroupController)