Created
September 2, 2013 18:24
-
-
Save ianjosephwilson/6415766 to your computer and use it in GitHub Desktop.
pyramid save off url in forbidden view
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def redirect_if_not_logged_in(request): | |
if request.user is None: | |
request.session['original_url'] = request.url | |
return HTTPFound(location=request.route_url( | |
request.registry.settings['auth.login_route_name'])) | |
return Forbidden() | |
def main(global_config, **settings): | |
#... | |
config.add_view(redirect_if_not_logged_in, context=Forbidden, | |
permission=NO_PERMISSION_REQUIRED) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment