> 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 hoop I didn't misunderstand the situation, but I think that I would
not pass animal_id to the assessments module at all, because it has
unique assessment_id on it's own (does it?). The assessment_id should
be sufficient to get all the information about assessment...
Ksenia.
Example for SCGI environment (should work in CGI too, I think):
in AnimalUI class:
def __init__(self):
self.id = None
def _q_index(self, request):
if self.id is None:
# show all animals
else:
# show one animal
def _q_lookup(self, request, component):
if component == 'assessment':
return AssessmentUI()
else:
try:
self.id = int(component)
except ValueError:
raise TraversalError
else:
return self
in AssessmentUI class:
def __init__(self):
self.id = None
def _q_index(self, request):
if self.id is None:
raise TraversalError # do not allow url like
/animal/x123/assessment/
else:
# show assessment
def _q_lookup(self, request, component):
try:
self.id = int(component)
except ValueError:
raise TraversalError
else:
return self