durusmail: quixote-users: keeping track of the modules/objects traversed
keeping track of the modules/objects traversed
2004-09-20
2004-09-20
2004-09-20
2004-09-20
2004-09-20
2004-09-21
2004-09-21
2004-09-20
keeping track of the modules/objects traversed
Titus Brown
2004-09-20
-> Sorry if this is an obvious question, but I'm fairly new to quixote
-> and I'm stumped on this issue.
->
-> I have a URL like the following:
->
-> http://some.url.com/myapp.cgi/animal/x123/assessment/234/
->
-> The basic idea is that for this animal inventory system there is an
-> assessment which has an id of 234 for animal with an id of x123.

[ ... ]

-> Ways I've thought of to do this:
-> - set value in module (doing this currently)
-> - set value in request (request.animal_id = 'x123', also yuck)
-> - parse the URL directly
-> - use urls like
-> http://some.url.com/myapp.cgi/animal-x123/assessment-234/
-> This lets me avoid directly traversing a module which seems to be the
-> thing that
-> is forcing me to set a global value where I would rather be setting an
-> instance variable.

I too use URLs like this in several places; I use a module hierarchy to
do it, e.g.  folder/__init__.py contains _q_lookup, so

        /canal/folder/

uses _q_lookup to look up  in the database, load corresponding
information, and return an object.

The only problem with it is that for deep URLs, e.g.

        /canal/lab/folder//group//analysis/

I have to do some module hackery to keep my source code hierarchy
from getting too deep.

Hope this helps!  I'd be interested in more elegant solutions, if anyone
has them...

cheers,
--titus

p.s. The source code for handling the above examples is under
        cartwheel.sf.net's CVS tree, /cartwheel/website/canal/.

reply