On 5/26/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> Hello!
>
> I am working on my first real Pylons application and so far everything
> is going really good!  Big thanks to all those involved for creating
> such a great web framework.
>
> I am just getting to adding users to my application.  I want to stop
> users from viewing data that isn't their own.  My gut reaction is to
> abort() and setup my error controller to display the error in a way
> that fits in with the rest of my application (using my Mako
> templates).  But I want to give the user a specific message about why
> they can't go there.
>
> So, I tried:
>
> abort(403, "Can't access another users data")
>
> The second argument is "detail" which gets passed to the
> paste.httpexceptions.HTTPForbidden object and thrown.  This seems like
> a really useful place to keep an application specific message.
> However, when the exception is converted to wsgi response by the
> paste.httpexceptions middleware, this information is lost.  So, that
> isn't going to work.
>
> My questions are:
>
>  (1) Is the exception object stored anywhere?  It would be great if it
> was dropped into the environ somewhere, but best I can tell from the
> paste source code, it isn't.
>
>  (2) Is there a better way to do this?  I imagine having lots of
> errors like this with simple one line messages.  I could create my own
> middleware to catch application specific exceptions and forward them,
> but this seems like overkill.  Is there a suggested way to accomplish
> this?
>
> Thanks in advance!

Yep, I've encountered this same difficulty.  In your case, probably
the best thing to do is to do a render_response using an error
template.  If you *really* want to take matters into your own hands,
write your own middleware that *wraps* the Paste exception handling
middleware.  I didn't do that, although I've done it for other things.
 Also, see the trick I wrote about here:

http://jjinux.blogspot.com/2007/03/python-returning-multiple-things-of.html

When I wrote that, I was facing the same issue you are facing.

Happy  Hacking!
-jj

-- 
http://jjinux.blogspot.com/

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To post to this group, send email to pylons-discuss@googlegroups.com
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