Пример #1
0
 def __before__(self):
     try:
         c.error_page = True
         RedditController.__before__(self)
     except:
         handle_awful_failure(
             "Error occurred in ErrorController.__before__")
Пример #2
0
    def pre(self):
        RedditController.pre(self)
        if g.disable_wiki and not c.user_is_admin:
            self.handle_error(403, 'WIKI_DOWN')
        if not c.site._should_wiki:
            self.handle_error(404, 'NOT_WIKIABLE')  # /r/mod for an example
        frontpage = c.site.is_homepage
        c.wiki_base_url = join_urls(c.site.path, 'wiki')
        c.wiki_api_url = join_urls(c.site.path, '/api/wiki')

        # CUSTOM
        if frontpage:
            c.wiki_base_url = join_urls('/', 'wiki')
            c.wiki_api_url = join_urls('/', '/api/wiki')

        c.wiki_id = g.default_sr if frontpage else c.site.name

        self.editconflict = False
        c.is_wiki_mod = (c.user_is_admin or c.site.is_moderator_with_perms(
            c.user, 'wiki')) if c.user_is_loggedin else False
        c.wikidisabled = False

        mode = c.site.wikimode
        if not mode or mode == 'disabled':
            if not c.is_wiki_mod:
                self.handle_error(403, 'WIKI_DISABLED')
            else:
                c.wikidisabled = True
Пример #3
0
 def __before__(self):
     try:
         c.error_page = True
         RedditController.__before__(self)
     except (HTTPMovedPermanently, HTTPFound):
         # ignore an attempt to redirect from an error page
         pass
     except:
         handle_awful_failure("Error occurred in ErrorController.__before__")
Пример #4
0
 def __before__(self):
     try:
         c.error_page = True
         RedditController.__before__(self)
     except HTTPFound:
         # ignore an attempt to redirect from an error page
         pass
     except:
         handle_awful_failure("Error occurred in ErrorController.__before__")
Пример #5
0
 def pre(self):
     RedditController.pre(self)
     if g.disable_wiki and not c.user_is_admin:
         self.handle_error(403, 'WIKI_DOWN')
     if not c.site._should_wiki:
         self.handle_error(404, 'NOT_WIKIABLE') # /r/mod for an example
     frontpage = isinstance(c.site, DefaultSR)
     c.wiki_base_url = join_urls(c.site.path, 'wiki')
     c.wiki_api_url = join_urls(c.site.path, '/api/wiki')
     c.wiki_id = g.default_sr if frontpage else c.site.name
     self.editconflict = False
     c.is_wiki_mod = (c.user_is_admin or c.site.is_moderator(c.user)) if c.user_is_loggedin else False
     c.wikidisabled = False
     
     mode = c.site.wikimode
     if not mode or mode == 'disabled':
         if not c.is_wiki_mod:
             self.handle_error(403, 'WIKI_DISABLED')
         else:
             c.wikidisabled = True
Пример #6
0
 def pre(self):
     RedditController.pre(self)
     if g.wiki_disabled and not c.user_is_admin:
         self.handle_error(403, 'WIKI_DOWN')
     if not c.site._should_wiki:
         self.handle_error(404, 'NOT_WIKIABLE') # /r/mod for an example
     frontpage = isinstance(c.site, DefaultSR)
     c.wiki_base_url = '/wiki' if frontpage else '/r/%s/wiki' % c.site.name
     c.wiki_id = g.default_sr if frontpage else c.site.name
     c.page = None
     c.show_wiki_actions = True
     self.editconflict = False
     c.is_wiki_mod = (c.user_is_admin or c.site.is_moderator(c.user)) if c.user_is_loggedin else False
     c.wikidisabled = False
     
     mode = c.site.wikimode
     if not mode or mode == 'disabled':
         if not c.is_wiki_mod:
             self.handle_error(403, 'WIKI_DISABLED')
         else:
             c.wikidisabled = True
Пример #7
0
 def pre(self):
     self.check_for_bearer_token()
     RedditController.pre(self)
Пример #8
0
 def __call__(self, environ, start_response):
     try:
         return RedditController.__call__(self, environ, start_response)
     except:
         return handle_awful_failure("something really awful just happened.")
Пример #9
0
 def pre(self):
     self.check_for_bearer_token()
     RedditController.pre(self)
Пример #10
0
 def on_validation_error(self, error):
     RedditController.on_validation_error(self, error)
     if error.code:
         self.handle_error(error.code, error.name)
Пример #11
0
 def on_validation_error(self, error):
     RedditController.on_validation_error(self, error)
     if error.code:
         self.handle_error(error.code, error.name)
Пример #12
0
 def pre(self):
     RedditController.pre(self)
     require_https()
Пример #13
0
 def __call__(self, environ, start_response):
     try:
         return RedditController.__call__(self, environ, start_response)
     except:
         return handle_awful_failure(
             "something really awful just happened.")
Пример #14
0
 def __after__(self): 
     try:
         RedditController.__after__(self)
     except:
         handle_awful_failure("Error occurred in ErrorController.__after__")
Пример #15
0
 def __before__(self):
     try:
         c.error_page = True
         RedditController.__before__(self)
     except:
         handle_awful_failure("Error occurred in ErrorController.__before__")
Пример #16
0
 def __call__(self, environ, start_response):
     try:
         return RedditController.__call__(self, environ, start_response)
     except:
         c.response.content = "something really awful just happened"
         return c.response
Пример #17
0
 def __after__(self):
     try:
         RedditController.__after__(self)
     except:
         pass
Пример #18
0
 def __before__(self):
     try:
         RedditController.__before__(self)
     except:
         pass
Пример #19
0
 def pre(self):
     RedditController.pre(self)
     require_https()
Пример #20
0
 def __after__(self):
     try:
         RedditController.__after__(self)
     except:
         handle_awful_failure("Error occurred in ErrorController.__after__")