[Zope] get Folder object from string name

Dirk Datzert Dirk.Datzert@rasselstein-hoesch.de
Wed, 02 Jan 2002 20:43:48 +0100


John Hunter schrieb:

> I have a string that contains the name of a folder, and I want to add
> files to that folder with a Script(Python) method add_file_to_folder.
> The name of the folder is contained in the REQUEST object field 'id'.
> If eval worked, I could do:
>
> eval("context.Patients.%s.manage_addFile(id='', file=REQUEST.get('file'))" %
>      REQUEST.get('id'))
>

I would try:

folder = getattr(context.Patients, REQUEST['id'])
folder.manage_addFile (...)


>
> (So the folder I want to write to is a subfolder of 'Patients'.)
>
> But eval doesn't work in a python script.  I could use an External
> Method, but I suspect there is a good way to do this using the Zope
> API.  Suggestions?
>
> Thanks a bunch,
> John Hunter
>
> _______________________________________________
> Zope maillist  -  Zope@zope.org
> http://lists.zope.org/mailman/listinfo/zope
> **   No cross posts or HTML encoding!  **
> (Related lists -
>  http://lists.zope.org/mailman/listinfo/zope-announce
>  http://lists.zope.org/mailman/listinfo/zope-dev )