[Zope] Creating subobjects Programmatically in a ZClass Instance
J. Cameron Cooper
jccooper at jcameroncooper.com
Fri Sep 26 17:20:28 EDT 2003
> What I am trying to do today is to create subobject in a Folderish
> ZClass (much like OFS:Folder automagically create and acl_uer folder
> and an index_html),
> but I cannot find an example....
>
> To illustrate, I create a ZClass folder deived instance called "FOO"
> Then within my new instance of "FOO" I want to create another ZClass
> folder derived instance called "BAR"
>
> All of this when the user creates the instance FOO
Quoth Appendix B:
"""
To create an object inside an object manager use |manage_addProduct|:
self.manage_addProduct['OFSP'].manage_addFolder(id, title)
"""
Here, 'manage_addFolder' is the constructor for 'Folder' but you'd
replace this with the constructor of your ZClass "BAR". (Note that
'self' refers to the ObjectManager to which you're adding an object. In
a Python script, which I think is how you do methods in a ZClass, this
is 'container' or 'context'.)
Put that in the constructor of "FOO" and you got it.
The actual mechanics of this I can't help you with, as I don't use ZClasses.
--jcc
--
"My point and period will be throughly wrought,
Or well or ill, as this day's battle's fought."
More information about the Zope
mailing list