Hi everyone,
I have an exception view configured with the view_config decorator
that is not catching my exception when it is raised while rendering my
template.
I am wondering if this is desired behaviour.
Here is a simplified example of what I'm doing.
The Exception View:
@view_config(context=ConnectionError, permission=NO_PERMISSION_REQUIRED)
def error_view(context, request):
""" Catch connection errors. """
request.flash('Could not connect. Please verify connection
settings. Error: {0}'.format(context)) # custom flash implementation
return HTTPFound(request.current_route_path(action='edit')) # Go
back to the edit page to modify server settings
The ConnectionError is raised in the view context:
class ServerFactory(RootFactory):
...
def client(self):
""" Connect to server. """
server = db.query(Server).get(self.server_id)
try:
return make_client(server.ip, server.port)
except:
raise ConnectionError('Could not connect.')
def model_number(self):
""" Get the model number of the server. """
client = self.client
return client.model_number()
If I make a call to ServerFactory.model_number inside of my Mako
templates, the ConnectionError not caught by error_view; however, if I
raise the ConnectionError in another view-callable it is caught.
Ideas?
--
Ian Marcinkowski
[email protected]
--
You received this message because you are subscribed to the Google Groups
"pylons-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/pylons-discuss?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.