[Zope] Creating an instance of another class?

J Cameron Cooper xdoclet at jcameroncooper.com
Fri Feb 6 16:10:07 EST 2004


J C Lawrence wrote:

>On Thu, 5 Feb 2004 19:39:22 +0100 
>Dieter Maurer <dieter at handshake.de> wrote:
>  
>
>>J C Lawrence wrote at 2004-2-4 20:25 -0500:
>>    
>>
>>>What is the correct way to use the OFS to create an instance of a
>>>product within an object?
>>>      
>>>
>><objectManagerDestination>.manage_addProduct[<productName>].
>><constructor>(<arguments>)
>>    
>>
>This is not moving as elegantly as I'd expected.  Any example cases out
>there?
>
This only works on ObjectManagers. It is very common, and you can find 
examples on zopelabs.com.

If you want to add to a property on a non-folderish object, you must do 
it the usual Python way, with the constructor.

See the bottom of
http://cvs.zope.org/CMF/CMFDefault/DiscussionTool.py?rev=1.17&content-type=text/vnd.viewcvs-markup
for an example.

          --jcc

-- 
"He who fights with monsters should look to it that he himself does not become a monster. And when you gaze long into an abyss the abyss also gazes into you."




More information about the Zope mailing list