[Zope3-Users] Two content objects' simultaneous adding

Ron Bickers rbickers-list-zope3 at logicetc.com
Sat May 20 17:09:59 EDT 2006


On Sat May 20 2006 04:47, baiju m wrote:

> I have two content objects (both are containers) but I cannot add one
> to another as give here :
>
>     def create(self, data):
>         square = Square()
>         square.name = data['name']
>         square.description = data['description']
>         company = Company()
>         company.name = data['companyname']
>         company.description = data['companydescription']
>         square['Comp1'] = company
>         ...
>         return square
>
> It was working in 3.2, now NotYet error is coming in 3.3. Here is the
> traceback:

I did this very thing a couple days ago in 3.3 and it works for me, except 
that I'm using zope.app.zapi.createObject to create the instances of my 
content objects.  So, maybe this:

from zope.proxy import removeAllProxies
from zope.app.zapi import createObject

def create(self, data):
    square = removeAllProxies(createObject(u"name.of.your.Square.Factory"))
    square.name = data['name']
    square.description = data['description']
    company = removeAllProxies(createObject(u"name.of.your.Company.Factory"))
    company.name = data['companyname']
    company.description = data['companyanydescription']
    square['Comp1'] = company
    ...
    return square

I'm not sure if/why the removeAllProxies is needed as I stole this procedure 
from the list archives.  Also, I'm about 1 week into my Zope3 development 
experience, so don't just take my word for it even if it works. :-)

-- 
Ron


More information about the Zope3-users mailing list