durusmail: quixote-users: _q_exception_handler during _q_lookup
_q_exception_handler during _q_lookup
2003-05-27
Jason Sibre (2 parts)
2003-06-16
Jason Sibre (2 parts)
_q_exception_handler during _q_lookup
Jason Sibre
2003-05-27
Hi folks,

This is primarily directed to the maintainers, but all insight is welcome.

I'm still new-ish with Quixote, having only tinkered with the demo, and
written one very simple web app using it.  I'm currently working on a more
ambitious application, which is ultimately still just a learning exercise.

Tonight, some time was spent threading my way through the calls in the
Publisher class (I'm actually using the SessionPublisher), and I finally
realized WHY my _q_lookup exceptions weren't being handled as I expected.
The scenario is that I have one object looked up in the root of the
url-space, (a WProject, which is a sub-class of WItem), which then in turn
uses _q_lookup to lookup further components within it (resolving to WTasks,
also sub-classes of WItem).  My problem was that when a task was missing
(TaskMissingError, one of my sub-classes of TraversalError), I couldn't
handle the exception that arose upon a _q_lookup failure in the object doing
the _q_lookup.  Instead, I had to handle it in the _q_exception_handler at
the web app's root level (the first object in the namespace stack).

Well, I poked around a while and finally figured out that the reason for the
behavior is that the namespace_stack that is being created in _traverse_url
doesn't get 'committed' to the Publisher, unless _traverse_url returns
cleanly.  Otherwise, the only item in the stack is the root_namespace...

So here's the reason for my e-mail to you:

Is there a good reason for NOT allowing _traverse_url to directly update the
namespace_stack, and hence allow objects traversed to have a chance to
handle TraversalError exceptions (or other exceptions that may occur during
_traverse_url) ?

It's a simple matter to modify _traverse_url and Publisher to allow them to
work directly on Publisher.namespace_stack, and in fact the patch to do so
is attached, but I'm not sure there isn't a good reason for it not being
done already, since it's so simple.

Please let me know what you think, and I'll test my patch further tomorrow.
After I get some rest...

By the way, guys, thanks for all your effort on Quixote, I'm really enjoying
working with it.

Thanks,

Jason Sibre
reply