[Zope] Changing context in Python Script

Dan Shafer pydan@danshafer.com
Thu, 16 May 2002 09:06:07 -0700


Thanks, Maik!

This was the missing piece:

folderObj=getattr(context,folderName)

I guess you only learn this stuff by asking. I sure couldn't find it on my 
own in the docs!

It's exactly what I need.
At 10:00 AM 5/16/2002 +0200, Maik Jablonski wrote:
>On Thu, 2002-05-16 at 09:33, Dan Shafer wrote:
> > Given the need for a Python script to:
> >
> > a. create a new folder whose name is stored in a variable called folderName
> > b. within that folder create a new doc whose name is stored in a variable
> > called docName
> >
> > what is the appropriate syntax? I can see that I need to change the 
> context
> > but I can't find anything on how to do that.
>
>hi,
>
>use something like this:
>
># create Folder in context
>
>context.manage_addFolder(folderName)
>folderObj=getattr(context,folderName)
>
># create DTMLDoc in new folder
>
>folderObj.manage_addDTMLDocument(docName)
>docObj=getattr(folderObj,docName)
>
>... from here you can manipulate docObj ...
>
>regards, maik
>--
>maik jablonski                    http://www.sachunterricht-online.de
>  universitaet bielefeld          http://www.zfl.uni-bielefeld.de
>   zentrum fuer lehrerbildung    tlph://+49.(0).521.106.4234