[Zope] Error Value: Can't pickle objects in acquisition wrappers

2006-05-22 Thread jose carlos
Hi,

I have a product with a container class to save a list of groups and
others objects..

The container class is:

class StorageAdapter(ObjectManager, BasicUserFolder):



this class have a function to add groups like that:

def addGroup(self, id=, nombre=, REQUEST =None):
to add a new group

#create a group
grupo = Group(id, nombre)
#add a group to container
try:
self._objects=self._objects+
({'id':id,'meta_type':Group.meta_type},)
self._setOb(id,grupo)
object=self._getOb(id) 
self._p_changed = 1
except: return MessageDialog(
title  ='error',
message='error al añadir grupo',
)
if REQUEST is not None:

REQUEST['RESPONSE'].redirect(self.absolute_url()+'/gestGroupForm') 


The class group is simple like this.

class Group(ObjectManager, BasicUserFolder):
Class Group

meta_type = 'Group'
title='Grupo'

def __init__(self, id, nombre):

_debug(init del Group)

self.id=id 
self.nombre=nombre 
#acl to control this group
f=AclUserFolder()   
_debug(creo el acl del Group)
try:self._setObject('acl_users', f)
except: return MessageDialog(
title  ='error Acl Existente',
message='Este Group ya contiene un ACL',
)
self.__allow_groups__=self.acl_users 

...
...
...

the function addGroup is called from a dtml and the groups are added ok
and later I can view the result perfectly in dtml, but i want to add a
new attribute to class group then in the method __init__  i have add the
sentence:

self.contacts=[]

this is the only change and then i obtain this error:

2006-05-22T16:29:14 ERROR Zope.SiteErrorLog
http://localhost:8080/prueba/ST/addGroup
Traceback (most recent call last):
  File /usr/lib/zope/lib/python/ZPublisher/Publish.py, line 119, in
publish
transactions_manager.commit()
  File /usr/lib/zope/lib/python/Zope2/App/startup.py, line 234, in
commit
transaction.commit()
  File /usr/lib/zope/lib/python/transaction/_manager.py, line 84, in
commit
self.get().commit(sub)
  File /usr/lib/zope/lib/python/transaction/_transaction.py, line 381,
in commit
self._saveCommitishError() # This raises!
  File /usr/lib/zope/lib/python/transaction/_transaction.py, line 379,
in commit
self._commitResources()
  File /usr/lib/zope/lib/python/transaction/_transaction.py, line 424,
in _commitResources
rm.commit(self)
  File /usr/lib/zope/lib/python/ZODB/Connection.py, line 462, in
commit
self._commit(transaction)
  File /usr/lib/zope/lib/python/ZODB/Connection.py, line 503, in
_commit
self._store_objects(ObjectWriter(obj), transaction)
  File /usr/lib/zope/lib/python/ZODB/Connection.py, line 525, in
_store_objects
p = writer.serialize(obj)  # This calls __getstate__ of obj
  File /usr/lib/zope/lib/python/ZODB/serialize.py, line 330, in
serialize
return self._dump(meta, obj.__getstate__())
TypeError: Can't pickle objects in acquisition wrappers.


i don't known where can be my error, if someone can help me.

thank

jose carlos

___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] Error Value: Can't pickle objects in acquisition wrappers

2006-05-22 Thread Gabriel Genellina

At Monday 22/5/2006 12:24, jose carlos wrote:


I have a product with a container class to save a list of groups and
others objects..



TypeError: Can't pickle objects in acquisition wrappers.


That means that you have an object with an attribute that is 
acquisition-wrapped.

That is, self.xxx is not a pure object but has an acquisition wrapper.

From the posted code it is not clear, but:
f=AclUserFolder()
try:self._setObject('acl_users', f)
might fail is AclUserFolder() returns an existing, wrapped, user folder.
Or maybe id,nombre are not exactly what you expect.

The error message is not very informative, try adding at least 
object._p_oid to see which object is failing.




Gabriel Genellina
Softlab SRL 




_ 
Horóscopos, Salud y belleza, Chistes, Consejos de amor: 
el contenido más divertido para tu celular está en Yahoo! Móvil. 
Obtenelo en http://movil.yahoo.com.ar

___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
http://mail.zope.org/mailman/listinfo/zope-announce

http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] Error Value: Can't pickle objects in acquisition wrappers

2006-05-22 Thread Dieter Maurer
jose carlos wrote at 2006-5-22 17:24 +0200:
I have a product with a container class to save a list of groups and
others objects..

You must take care not to store values containing (or being)
AcquisitionWrappers in attributes of persistent objects.

-- 
Dieter
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )