def __before__(self): try: c.error_page = True RedditController.__before__(self) except: handle_awful_failure( "Error occurred in ErrorController.__before__")
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
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__")
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__")
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
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
def pre(self): self.check_for_bearer_token() RedditController.pre(self)
def __call__(self, environ, start_response): try: return RedditController.__call__(self, environ, start_response) except: return handle_awful_failure("something really awful just happened.")
def on_validation_error(self, error): RedditController.on_validation_error(self, error) if error.code: self.handle_error(error.code, error.name)
def pre(self): RedditController.pre(self) require_https()
def __call__(self, environ, start_response): try: return RedditController.__call__(self, environ, start_response) except: return handle_awful_failure( "something really awful just happened.")
def __after__(self): try: RedditController.__after__(self) except: handle_awful_failure("Error occurred in ErrorController.__after__")
def __before__(self): try: c.error_page = True RedditController.__before__(self) except: handle_awful_failure("Error occurred in ErrorController.__before__")
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
def __after__(self): try: RedditController.__after__(self) except: pass
def __before__(self): try: RedditController.__before__(self) except: pass