Error Value: Can't pickle objects in acquisition wrappers
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
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
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
Hi all, i'm trying to show a Image object in dtml but i don known how to do it. i have a user object and this user have a jpg foto atributte. this foto atributte is a instance of OFS.Image and when i try to view in dtml only view Ascii character.. i think about to create a temporary file and then in dtml use that url but i dont like that solution. i would like hear any ideas.. thanks
--On 21. Juni 2006 10:00:12 +0200 jose carlos <jcsenciales@citic.es> wrote:
Hi all,
i'm trying to show a Image object in dtml but i don known how to do it.
i have a user object and this user have a jpg foto atributte. this foto atributte is a instance of OFS.Image and when i try to view in dtml only view Ascii character..
i think about to create a temporary file and then in dtml use that url but i dont like that solution.
Do you have the real need for using DTML? I assume you are new to Zope and you should really remove DTML from your memory and replace it with ZPT in this case. This is definitely the way to go for a newbie. -aj
Andreas Jung schrieb:
--On 21. Juni 2006 10:00:12 +0200 jose carlos <jcsenciales@citic.es> wrote:
Hi all,
i'm trying to show a Image object in dtml but i don known how to do it.
i have a user object and this user have a jpg foto atributte. this foto atributte is a instance of OFS.Image and when i try to view in dtml only view Ascii character..
i think about to create a temporary file and then in dtml use that url but i dont like that solution.
Do you have the real need for using DTML? I assume you are new to Zope and you should really remove DTML from your memory and replace it with ZPT in this case. This is definitely the way to go for a newbie.
This isnt even a job for ZPT or any other template language at all ;) Regards Tino
jose carlos schrieb:
Hi all,
i'm trying to show a Image object in dtml but i don known how to do it.
i have a user object and this user have a jpg foto atributte. this foto atributte is a instance of OFS.Image and when i try to view in dtml only view Ascii character..
i think about to create a temporary file and then in dtml use that url but i dont like that solution.
i would like hear any ideas..
<img src="/path/to/userobject/imageattribute" witdh="..." height="..." alt="the user" /> maybe? If you cant access the userobject by path, a small wrapper (python script) should do it: if traverse_subpath: return context.acl_users.getUser(traverse_subpath[0]).imageattribute.data then you can have above link in your HTML image tag like /path/to/the/pythonscript/userid which would return, when called by the subsequent browser request, just the image data.
thanks doing a small python script and calling to url script like you tell me, show the image perfectly. thanks On Wed, 2006-06-21 at 10:31 +0200, Tino Wildenhain wrote:
jose carlos schrieb:
Hi all,
i'm trying to show a Image object in dtml but i don known how to do it.
i have a user object and this user have a jpg foto atributte. this foto atributte is a instance of OFS.Image and when i try to view in dtml only view Ascii character..
i think about to create a temporary file and then in dtml use that url but i dont like that solution.
i would like hear any ideas..
<img src="/path/to/userobject/imageattribute" witdh="..." height="..." alt="the user" />
maybe?
If you cant access the userobject by path, a small wrapper (python script) should do it:
if traverse_subpath: return context.acl_users.getUser(traverse_subpath[0]).imageattribute.data
then you can have above link in your HTML image tag like
/path/to/the/pythonscript/userid
which would return, when called by the subsequent browser request, just the image data.
participants (5)
-
Andreas Jung -
Dieter Maurer -
Gabriel Genellina -
jose carlos -
Tino Wildenhain