On Mar 24, 10:45 am, edgarsmolow <[email protected]> wrote:
> Thanks, Tom.
> But that document is out-of-date.  After reading that document, I
> still don't understand the process or have a good example to follow.
> Besides, ErrorController might not be what I'm looking for.  What
> happens when a URL identifies a specific controller and action, but
> the action has not been implemented?  For 
> instance,http://domain.com/products/view
> would map to the view action in the products controller. But, if the
> view action (method) does not exist, Pylons throws and exception.  How
> do I handle that situation?

The ErrorHandler middleware in config/middleware.py handles these
exceptions (returning a debug page or sending an email, depending on
whether you're in debug mode). You could subclass that middleware and
check for that particular exception.

The StatusCodeRedirect middleware also comes into play for unhandled
exceptions when not in debug mode. The NotImplementedError you get in
your example would cause a 404 error[1], so you could edit the
ErrorController to return a certain page for status code 404 +
specific exception. I've done this type of thing before, creating a
templates/errors directory with templates named 404.html, 500.html,
etc.

Another option would be to figure out where Pylons calls your action
method, catch the NotImplementedError, and abort 404. You might be
able to do this in your BaseController's __call__ method...

Actually, looking at code for Pylon's WSGIController, it already
returns a 404 response for a missing action when not in debug mode, so
unless you want to do something other than return a 404 page to the
user, you're already covered.

--

[1] not a 500 error like I first thought.
--~--~---------~--~----~------------~-------~--~----~
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