[Zope] How to create zope objects without using the ZMI?

Johan Carlsson johanc at easypublisher.com
Wed Dec 29 03:45:27 EST 2004


robert wrote:
> Michael Lee wrote:
> 
>> Is there another way to create zope object? Is it possible to write a 
>> python script to create object, say a file or a page template? If the 
>> answer is yes, how?
>>
>> Thanks in advance.
>> Michael

Hi Michael,
What you should look at in the manual is
Appendix :: module ObjectManager:

It states that:
"""
An ObjectManager contains other Zope objects. The contained objects are 
Object Manager Items.

To create an object inside an object manager use manage_addProduct:
   self.manage_addProduct['OFSP'].manage_addFolder(id, title)

[My Note]
In a PythonScript you can use:

context.manage_addProduct['OFSP'].manage_addFolder(id, title)

[/My Note]

In DTML this would be:
   <dtml-call "manage_addProduct['OFSP'].manage_addFolder(id, title)">

These examples create a new Folder inside the current ObjectManager.

manage_addProduct is a mapping that provides access to product 
constructor methods. It is indexed by product id.

Constructor methods are registered during product initialization and 
should be documented in the API docs for each addable object.

[My Note]
E.g.
'OFSP', manage_addFolder, and the arguments to manage_addFolder
will be different for diffrent objects.
OFSP is the Products for regular Zope objects (Image, File, Folder ( 
Ordered Folder), DTML Method etc).
[/My Note]
"""



-- 
Johan Carlsson          Tel: + 46 8 31 24 94
Colliberty              Mob: + 46 70 558 25 24
Torsgatan 72            Email: johanc at easypublisher.com
SE-113 37 STOCKHOLM


More information about the Zope mailing list