On 3/7/07, chris e <[EMAIL PROTECTED]> wrote:
>
> In my web app I have a need to verify that there is an authenticated
> user with appropriate privileges  before displaying any page in the
> app. If there is not an authenticated user, then I need to display an
> appropriate warninginsufficient privileges page. Currently the way I
> have implemented this is to write a base controller class that
> provides the __before__ method which is then used as the parent class
> for all other controllers in the app. However, I've run into the issue
> that from the __before__ method you cannot simply  return content, and
> have it displayed to the user. It appears that you have to do a
> redirect_to, which ends up doing a redirect and changing the URL. What
> I would like to do is render a page from the __before__ method, and
> have that be what is displayed to the user(similar to the way that
> HTTP exceptions are handled). Is there a way to do this??

You can put it in the base template .__call__ method:

if not_logged_in:
    redirect_to_login()
if insufficient privilege:
    abort(401, "You're outta here, bozo.")   # In pylons.helpers
return WSGIController.__call__(self, environ, start_response)

-- 
Mike Orr <[EMAIL PROTECTED]>

--~--~---------~--~----~------------~-------~--~----~
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