durusmail: quixote-users: TraversalError, not enough info?
TraversalError, not enough info?
2004-03-18
2004-03-23
2004-04-14
TraversalError, not enough info?
Evan LaForge
2004-03-18
I have this situation:

An object 'x' which has some (dynamically generated) subobjects, etc.  In the
event that they don't exist (say the user has a bookmark from an older
session), I want:

/x/exists1/exists2/doesnt_exist1/doesnt_exist2 -> (redirect to) ->
/x/exists1/exists2/ (with msg "doesnt_exist1/doesnt_exist2" doesn't exist")

Currently, my code snags TraversalError in x._q_exception_handler and
redirects to '..' and the client just keeps bouncing up until it hits an
object that does exist.  Multiple identical "doesn't exist" messages are
controlled with some light hackery.

What I really want is a way to redirect directly to the deepest existing
object, and how I think I want to do that is for TraversalError to report more
precisely where the traversal failed.  This could be done if TraversalError
had 3 attributes: path_before, component, path_after.  The complete
request.get_path() would be path_before + '/' + component + '/' + path_after.
This means _get_component would need the whole path as yet another argument,
and seems like a lot of work to just handle the above situation.  So if
there's another way I'm interested.  However, I also point out that currently
TraversalError.path is inconsistent: if the final path component had the error
(not a string, not callable) it is the complete path, but if any other
component had the error (not traversable) it is merely the component in
question.


personal stuff:

If anyone remembers I was here about 2 years ago working on a webmail thing in
quixote.  I got it almost usable and then went to Indonesia for around a year
and a half, during which I didn't have a computer.  So all this htmltext stuff
is new and interesting to me.  I've dusted off my old project, after a number
of hard drive crashes, and may be finishing it one of these days, or years :)


reply