[Zope] getitem from python

Roman Bogoyev roman@maths.uwa.edu.au
Wed, 29 May 2002 18:24:41 +0800


Please excuse this newbie question:

How do I refer to an object from a variable in a python script?

eg:  

Have a document named 'mydoc' in the current folder where this
script lives:

print context.mydoc.title_or_id() 

works but I want

fred = 'mydoc'
print context.fred.title_or_id()

which obviously doesn't. So I need to 
turn the string 'mydoc' into an object
reference.  Something like the dtml 'getitem'?? 
-- 


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Roman Bogoyev, Computer Systems Manager,      email: roman@maths.uwa.edu.au
UWA Maths, 35 Stirling Hwy, Crawley,          phone: +61 8 9380 3379
Western Australia 6009                        fax: +61 8 9380 1028