[Zope] Inserting a variable in a context.manage statement in Python

Dan Shafer pydan@danshafer.com
Mon, 22 Apr 2002 16:55:49 -0700


Is it possible to insert into a context.manage* statement a variable 
previously assigned in a Python script? If so, what's the syntax?

I have the following:

c = REQUEST.get('clearing_id','')
context.manage_addFolder(c) # this works
# Now what I want to do is add a document to the folder
# If I include a hard-coded value for the folder name I just created as a 
test, it works
# But this doesn't:
context.c.manage_addDocument('NewDoc')

I always get an AttributeError on 'c' which, if I understand correctly, is 
telling me that internally Zope is trying to do a getattr() on something to 
resolve c and not being able to do so.

I'm guessing I need some kind of delimiter around the variable c here but 
I'm darned if I can figure out what that might be! I have tried every 
combination I could come up with after perusing the HOW-TO and Tip files 
for Zope, to no avail. Assuming the manage_addDocument method ends up 
calling addDTMLDocument in DTMLDocument.py, II can't see for the life of me 
why what I'm doing doesn't work. But it doesn't.