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
Dustin Lee
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.  I
have the keyword assessment in there because there are other entities
associated with an animal id so I don't know what the object id
following x123 refers to unless I also give the name.  The question is
when I instantiate the assessment (234) is there an easy way to
determine what the animal id was?  the object referred to by 234 is an
AssessmentUI object in the assessment_ui module.

Right now I'm using a hack which I'm sure isn't right, but is working
enough to let me get some work done.  Basically the AnimalUI class
(instantiated on x123) has a _q_lookup method that returns the
assessment_ui module when the component == 'assessment'.  And then to
pass the animal_id info along it (prepare to experience pain due to
ugly hack) sets the animal_id var in the assessments module.  I'm
pretty sure this is only working for me right now because I'm using
straight CGI.  Seems like there should be a more elegant way for a
down stream class to see what values were set earlier on.

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.

Seems like this is something that folks must do all the time, or maybe
I'm just thinking about this is a weird way.

Anyway,  hope my question makes sense.

thanks,

dustin


--
Dustin Lee
qhfgva=rot13(dustin)

reply