[Zope] How do I eval a variable within the acquisition path?

robert rottermann robert at redcor.ch
Wed Aug 22 00:19:32 EDT 2007


Tim Nash schrieb:
> I apologize for the question (the zope area of my brain must need
> coffee) but I can't find the answer in the zope book or in any of the
> scripts posted to the zope cookbook.
> 
> I want to use a variable in a acquisition path.
> 
> So for example, from the zope book on scripts, imagine that
> vaccinateplan() printed out a specific animals vaccination plan.
> 
> Now instead of saying 'LargeAnimals' and 'hippo' like so:
> 
> print context.Vet.LargeAnimals.hippo.vaccinateplan()
> 
> I want to do like this:
> 
> category = REQUEST.form['category']
> animal = REQUEST.form['animal']
> 
> print context.Vet.category.animal.vaccinateplan()
print context.Vet[category]
or
print getattr(context.Vet, category, 'some default value')
hth
robert
-------------- next part --------------
A non-text attachment was scrubbed...
Name: robert.vcf
Type: text/x-vcard
Size: 211 bytes
Desc: not available
Url : http://mail.zope.org/pipermail/zope/attachments/20070822/c68951c7/robert.vcf


More information about the Zope mailing list