Hello,

I've tried searching all over the documentation and the web, but
please pardon me if I missed the answer.

I'm in the process of migrating from Pylons 1.0 to Pyramid and I'm
wondering how I should present a login form when using pyramid's
handlers?  I only want this login form to display if the user is not
logged in.  If they are logged in and don't have access to the page
the forbidden page should be displayed.

Ideally I'd like an action to be called to set up some variables in
the template; for example:

    config.add_handler('display_login', '/login',
'appname.handlers.auth:AuthHandler', action='display_login',
request_method='GET')

 
@action(renderer='login.mako')
    def
display_login(self):
        """Display the login
form."""
        return {'error_count': 0, 'came_from': self.request.url}

I tried using config.add_view() ala:

    config.add_view(renderer='appname:templates/login.mako',
context='pyramid.exceptions.Forbidden')

and it sort of works but it simply renders the template (as expected)
rather than "redirecting" to /login.  My guess is that would also
display the login page in the second case where the user is logged in
but does not have access.

So how to do this properly?  Thanks for your replies and let me know
if you need any other code from my app to help diagnose.

Cheers
Walden

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en.

Reply via email to