#45 — Pickle Objects in Acquistion Wrappers

by Beren Erchamion last modified Jan 08, 2009 04:21 PM
State Postponed
Version: 1.5
Area Functionality
Issue type Bug
Severity Medium
Submitted by Beren Erchamion
Submitted on Jul 27, 2006
Responsible Justin Ryan
Target release: 1.6


I was using the 1.5 beta with Zope2.9.3/Plone2.5 and with a new blog if I a keyword I get the following error.

beren


2006-07-26 22:56:29 ERROR Zope.SiteErrorLog http://wrndusitrd95:9191/IM/roundtab
le/jeff-s-palantir/test/base_edit
Traceback (most recent call last):
  File "C:\Zope\lib\python\ZPublisher\Publish.py", line 121, in publish
    transactions_manager.commit()
  File "C:\Zope\lib\python\Zope2\App\startup.py", line 240, in commit
    transaction.commit()
  File "C:\Zope\lib\python\transaction\_manager.py", line 96, in commit
    return self.get().commit(sub, deprecation_wng=False)
  File "C:\Zope\lib\python\transaction\_transaction.py", line 380, in commit
    self._saveCommitishError() # This raises!
  File "C:\Zope\lib\python\transaction\_transaction.py", line 378, in commit
    self._commitResources()
  File "C:\Zope\lib\python\transaction\_transaction.py", line 433, in _commitRes
ources
    rm.commit(self)
  File "C:\Zope\lib\python\ZODB\Connection.py", line 484, in commit
    self._commit(transaction)
  File "C:\Zope\lib\python\ZODB\Connection.py", line 526, in _commit
    self._store_objects(ObjectWriter(obj), transaction)
  File "C:\Zope\lib\python\ZODB\Connection.py", line 553, in _store_objects
    p = writer.serialize(obj) # This calls __getstate__ of obj
  File "C:\Zope\lib\python\ZODB\serialize.py", line 407, in serialize
    return self._dump(meta, obj.__getstate__())
  File "C:\Zope\lib\python\ZODB\serialize.py", line 416, in _dump
    self._p.dump(state)
TypeError: Can't pickle objects in acquisition wrappers.
Added by Maurits van Rees on Aug 14, 2006 09:02 PM
Target release: 1.6None
Responsible manager: justizin(UNASSIGNED)
I can't confirm this. I'm not the most knowledgeable Quills user though, so don't despair. :)

But it seems there is a word missing in your report, which may be important. So can you clarify?

Quoting:
"I was using the 1.5 beta with Zope2.9.3/Plone2.5 and with a new blog if I [add? remove? something else?] a keyword I get the following error."

Also the keywords system for Quills has changed recently, going from its own system to using the usual plone keyword system. So maybe you caught Quills at a bad time. Can you try again please? Tim or someone else may have inadvertently solved this already. ;-)
Added by Beren Erchamion on Aug 15, 2006 01:49 AM
Sorry - its when I "add" a keyword.

I think I have the latest available release on the plone.org site. Is there a more recent release in svn? Can you supply the svn repo url?

beren
Added by Tim Hicks on Aug 15, 2006 11:54 AM
Try a checkout from http://svn.plone.org/svn/collective/Quills/trunk (or .../Quills/bundles/with-friends-trunk if you want to get hold of all the dependencies as well).

Please do report back if this problem persists even on the newer code.
Added by Justin Ryan on Aug 28, 2006 03:03 PM
Issue state: unconfirmedpostponed
Target release: None1.5
Responsible manager: (UNASSIGNED)justizin
Two things:

  (a) We're about to cut what we hope to be the final RC of Quills 1.5, which is targeted at Zope 2.9 and Plone 2.5, and should work in Zope 2.8.6+ and Plone 2.1.

  (b) point yourself at this bundle, rather than with-friends-trunk: http://svn.plone.org/[…]/latest-known-working

If you are still having this on a supported configuration of Plone, we'd like some details before we cut a 1.5 release.
Added by Beren Erchamion on Aug 30, 2006 01:43 AM
I checked the svn spot and I didn't see any files there? did you do the merge already?

beren
Added by Justin Ryan on Aug 30, 2006 02:38 AM
It's a bundle, it pulls Quills and some dependencies via the svn:external property.

Just grab the RC3 tarball. ;)
Added by Beren Erchamion on Aug 30, 2006 10:53 AM
Ah - duh - sorry. Not too familiar with the externals thing, but looks interesting. I grabbed the .tar and will give it a shot today.

beren
Added by Justin Ryan on Sep 08, 2006 12:51 AM
Beren - any progress?
Added by Beren Erchamion on Sep 09, 2006 10:33 PM
I'll test ASAP. I've been busy with PAS and Active Directory...

beren
Added by Romain on Sep 14, 2006 07:04 PM
I have the same problem with an image field inside an AGX generated content-type when creating the object(not when modify) in plone-2.5.
If you have any idea what the problem could be...
Added by Kiran Jonnalagadda on Sep 17, 2006 08:43 AM
Can confirm the "Can't pickle objects in acquisition wrappers" is still there with Python 2.4.3, Zope 2.9.4, Plone 2.5.1 and Quills 1.5.0.a3-dev10 off SVN Quills-with-friends (except Five, which is Plone 2.5.1's included version).

Previously, the error existed under Python 2.3.5, Zope 2.8, Plone 2.5 with included Five and Quills from svn (-dev3, IIRC, about two months old).
Added by Kiran Jonnalagadda on Sep 17, 2006 05:13 PM
Here's my traceback, this time using latest-known-working (but Five 1.3.7) on Plone 2.5.1 and Zope 2.9.4.

Traceback (innermost last):
  Module ZPublisher.Publish, line 115, in publish
  Module ZPublisher.mapply, line 88, in mapply
  Module ZPublisher.Publish, line 41, in call_object
  Module Products.CMFFormController.FSControllerPageTemplate, line 96, in __call__
  Module Products.CMFFormController.BaseControllerPageTemplate, line 39, in _call
  Module Products.CMFFormController.ControllerBase, line 245, in getNext
   - __traceback_info__: ['id = base_edit', 'status = success', 'button=None', 'errors={}', 'context=<WeblogEntry at weblogentry.2006-09-17.9237427638>', "kwargs={'portal_status_message': 'Changes saved.'}", 'next_action=None', '']
  Module Products.CMFFormController.Actions.TraverseTo, line 36, in __call__
  Module ZPublisher.mapply, line 88, in mapply
  Module ZPublisher.Publish, line 41, in call_object
  Module Products.CMFFormController.FSControllerPythonScript, line 108, in __call__
  Module Products.CMFFormController.Script, line 141, in __call__
  Module Products.CMFCore.FSPythonScript, line 108, in __call__
  Module Shared.DC.Scripts.Bindings, line 311, in __call__
  Module Shared.DC.Scripts.Bindings, line 348, in _bindAndExec
  Module Products.CMFCore.FSPythonScript, line 164, in _exec
  Module None, line 1, in content_edit
   - <FSControllerPythonScript at /sites/jace.seacrow.com/content_edit used for /sites/jace.seacrow.com/blog/weblogentry.2006-09-17.9237427638>
   - Line 1
  Module Products.CMFCore.FSPythonScript, line 108, in __call__
  Module Shared.DC.Scripts.Bindings, line 311, in __call__
  Module Shared.DC.Scripts.Bindings, line 348, in _bindAndExec
  Module Products.CMFCore.FSPythonScript, line 164, in _exec
  Module None, line 11, in content_edit_impl
   - <FSPythonScript at /sites/jace.seacrow.com/content_edit_impl used for /sites/jace.seacrow.com/blog/weblogentry.2006-09-17.9237427638>
   - Line 11
  Module Products.Archetypes.BaseObject, line 648, in processForm
  Module Products.Archetypes.BaseObject, line 750, in _renameAfterCreation
  Module transaction._manager, line 110, in savepoint
  Module transaction._transaction, line 295, in savepoint
  Module transaction._transaction, line 292, in savepoint
  Module transaction._transaction, line 675, in __init__
  Module ZODB.Connection, line 1012, in savepoint
  Module ZODB.Connection, line 526, in _commit
  Module ZODB.Connection, line 553, in _store_objects
  Module ZODB.serialize, line 407, in serialize
  Module ZODB.serialize, line 416, in _dump
TypeError: Can't pickle objects in acquisition wrappers.
Added by Kevin Teague on Sep 23, 2006 06:59 AM
I am getting "Can't pickle Object in acquisition wrappers" as well. Using Zope 2.9.3 with Plone 2.5.1-rc1 and latest-known-working (except Five). I was also getting pickle errors with 1.5-RC3 tarball.

I've worked around the issue by commenting out the self.migrateCategoriesForEntry(entry) call in the migrateWeblog method, and then doing an Uninstall/Reinstall. I can now add and publish posts.
Added by Kevin Teague on Sep 23, 2006 07:58 AM
It looks like the bug might be caused by this:

        # Add the two together
        subjects = existingSubjects[:] # Hard copy

This only creates a shallow copy of the entryCategories attribute. The following seems to work for me:

        # Add the two together
        import copy
        subjects = copy.deepcopy(existingSubjects)
Added by Tim Hicks on Sep 23, 2006 03:28 PM
kteague, thanks for digging into this issue.

Your proposed fix - which I assume is applied in Quills.migrations.quills09to15 - is interesting. It's not clear to me why the existing code::

  existingSubjects = list( entry.Subject() )
  subjects = existingSubjects[:]

should result in 'subjects' being Acquisition-wrapped.

I'm happy to apply the change, but I'd like to understand the reasoning for it first. Can you elaborate?

Further, it seems unlikely that your proposed fix will actually solve the issue for the original poster, Beren Erchamion, as he reports the problem on a "new blog", not a migrated one. Beren, can you verify that kteague's fix doesn't solve your problem? In fact, can you verify that you are still seeing this issue on 1.5RC3 (or a more recent svn checkout)?
Added by Beren Erchamion on Sep 23, 2006 05:09 PM
Yes I'm still seeing the issue as I originally posted with the latest Quills bundle from plone.org

-beren
Added by Kevin Teague on Sep 23, 2006 06:25 PM
Yeah, I don't see how that list would get acquisition wrapped, so maybe my 'fix' is of no help. I was Reinstalling the Quills product a lot (and fiddling with various bits here and there). Also, I did not fully test my upgraded Quills, I am getting the same bug as Beren where I can not add a keyword.

I do have a clean instance of my Plone before upgrading to Quills so maybe I will start over with the latest svn version of Quills.

- Kevin
Added by Kevin Teague on Sep 23, 2006 10:22 PM
I have just tried doing an Uninstall/Reinstall with Quills running latest-known-working from svn on a Plone 2.5.1 with Zope 2.9.3 (again using the Five 1.3.7). I get the following error upon install:

Traceback (innermost last):
  Module ZPublisher.Publish, line 121, in publish
  Module Zope2.App.startup, line 240, in commit
  Module transaction._manager, line 96, in commit
  Module transaction._transaction, line 370, in commit
  Module transaction._transaction, line 250, in _prior_operation_failed
TransactionFailedError: An operation previously failed, with traceback:

  File "/opt/Zope-2.9.3/lib/python/ZServer/PubCore/ZServerPublisher.py", line 23, in __init__
    response=response)
  File "/opt/Zope-2.9.3/lib/python/ZPublisher/Publish.py", line 393, in publish_module
    environ, debug, request, response)
  File "/opt/Zope-2.9.3/lib/python/ZPublisher/Publish.py", line 194, in publish_module_standard
    response = publish(request, module_name, after_list, debug=debug)
  File "/var/zope/instances/gsc_gin/Products/PlacelessTranslationService/PatchStringIO.py", line 34, in new_publish
  File "/opt/Zope-2.9.3/lib/python/ZPublisher/Publish.py", line 115, in publish
    request, bind=1)
  File "/opt/Zope-2.9.3/lib/python/ZPublisher/mapply.py", line 88, in mapply
    if debug is not None: return debug(object,args,context)
  File "/opt/Zope-2.9.3/lib/python/ZPublisher/Publish.py", line 41, in call_object
    result=apply(object,args) # Type s<cr> to step into published object.
  File "/var/zope/instances/gsc_gin/Products/CMFQuickInstallerTool/QuickInstallerTool.py", line 454, in installProducts
  File "/var/zope/instances/gsc_gin/Products/CMFQuickInstallerTool/QuickInstallerTool.py", line 326, in installProduct
  File "/opt/Zope-2.9.3/lib/python/transaction/_manager.py", line 96, in commit
    return self.get().commit(sub, deprecation_wng=False)
  File "/opt/Zope-2.9.3/lib/python/transaction/_transaction.py", line 366, in commit
    self._subtransaction_savepoint = self.savepoint(optimistic=True)
  File "/opt/Zope-2.9.3/lib/python/transaction/_transaction.py", line 295, in savepoint
    self._saveCommitishError() # reraises!
  File "/opt/Zope-2.9.3/lib/python/transaction/_transaction.py", line 292, in savepoint
    savepoint = Savepoint(self, optimistic, *self._resources)
  File "/opt/Zope-2.9.3/lib/python/transaction/_transaction.py", line 675, in __init__
    savepoint = savepoint()
  File "/opt/Zope-2.9.3/lib/python/ZODB/Connection.py", line 1012, in savepoint
    self._commit(None)
  File "/opt/Zope-2.9.3/lib/python/ZODB/Connection.py", line 526, in _commit
    self._store_objects(ObjectWriter(obj), transaction)
  File "/opt/Zope-2.9.3/lib/python/ZODB/Connection.py", line 553, in _store_objects
    p = writer.serialize(obj) # This calls __getstate__ of obj
  File "/opt/Zope-2.9.3/lib/python/ZODB/serialize.py", line 407, in serialize
    return self._dump(meta, obj.__getstate__())
  File "/opt/Zope-2.9.3/lib/python/ZODB/serialize.py", line 416, in _dump
    self._p.dump(state)
TypeError: Can't pickle objects in acquisition wrappers.

If I comment out the migrateCategoriesForEntry() call in Quills.migrations.quills09to15.py then the Installer runs without errors. Not that none of the WeblogEntry objects that I am migrating have any categories set, however the "# nothing to do here." return statement never gets called, it seems to try and migrate the empty categories anyways.

Added by Tim Hicks on Sep 24, 2006 01:54 PM
Kevin and Beren,

Can you try a trunk checkout of Quills now, please? I just made check-in that may help (but is untested by me), (http://dev.plone.org/collective/changeset/30905).

Tim
Added by Kevin Teague on Sep 25, 2006 02:26 AM
I thought perhaps entryCategories might be being acquired from elsewhere in my Plone, so I tried the latest svn verion, but no luck.

Further poking around inicates that I am simply not able to call setSubject(value) on a Weblog Entry. For example, I can get migration to work by just commenting out the "entry.setSubject(subjects)" line in Quills/migrations/quills09to15.py. Post migration I can add and edit blog entries, but I can not assign them Keywords. If I do Zope has kittens (can't pickle error).

Looking through the source I have no idea why this happens, but it does :(
Added by Kevin Teague on Sep 25, 2006 02:38 AM
It looks like this is caused by some interaction between Subjects and portal catalog. For example I can call the following Python script:

 # bingoballs is a Weblog Entry
 entry = context.bingoballs
 entry.setSubject('Cat and Dog')

This adds 'Cat and Dog' as a Keyword and works fine. However, if I try and reindex that Weblog Entry in the portal catalog, for example:

 # bingoballs is a Weblog Entry
 entry = context.bingoballs
 entry.reindexObject()

I get the Can't pickle error.
Added by Kevin Teague on Sep 25, 2006 03:05 AM
Fixed it!

It seems my problem was that there was a getCategories Keyword Index in my portal catalog (with 0 items in the index). I removed this from the indexes and metadata tabs of my portal catalog, and I can now add Keywords to Weblog Entries.

Note sure what added this index to my portal_catalog, although the Plone I was testing on has been around for a lot time so it's had a lot of Products added/removed to it over time.
Added by Kiran Jonnalagadda on Sep 26, 2006 05:32 AM
Removing getCategories from indexes and metadata fixed it for me too.
Added by Justin Ryan on Jan 09, 2007 02:22 AM
Issue state: postponedopen
this worked for me as well, where is getCatalogs coming from? An old / beta / alpha version of Quills, perhaps?
Added by Emyr Thomas on Mar 01, 2007 11:49 AM
Do you have PloneSoftwareCenter installed? This product adds getCategories to the catalog metadata (and catalog indexes too).
Added by Beren Erchamion on Mar 01, 2007 12:05 PM
Yes I do - one of the nest products for sure!

Does PSC require this catalog entry? I can try deleting it on a scratch instance and see what happens.
Added by Beren Erchamion on Mar 14, 2007 02:00 AM
I did some testing tonight and the getCategories index is required for PloneSoftwareCenter. If I delete this entry in the catalog then the main page will no longer display and I get a key error complaining that the index is missing. If I add the key back then it works again. The key is for the category field associated with projects and is used to build the main page just like on the products area here.

beren
Added by Matthew X. Economou on Jun 10, 2007 01:37 PM
I'm getting the same TypeError, but upon migration (0.9 to 1.5-branch) and with a very different traceback:

Traceback (innermost last):
  Module ZPublisher.Publish, line 121, in publish
  Module Zope2.App.startup, line 240, in commit
  Module transaction._manager, line 96, in commit
  Module transaction._transaction, line 380, in commit
  Module transaction._transaction, line 378, in commit
  Module transaction._transaction, line 433, in _commitResources
  Module ZODB.Connection, line 476, in commit
  Module ZODB.Connection, line 1012, in savepoint
  Module ZODB.Connection, line 526, in _commit
  Module ZODB.Connection, line 553, in _store_objects
  Module ZODB.serialize, line 407, in serialize
  Module ZODB.serialize, line 416, in _dump
TypeError: Can't pickle objects in acquisition wrappers.

I tried modifying the migration script to perform a deep copy, but that doesn't fix the error.
Added by Lucie Lejard on Aug 08, 2007 02:41 PM
I am using Zope 2.10.4-final, python 2.4.4 and Plone3-rc2.

I tried Quills today and, after fixing a typo [1], I have the "can't pickle object" error too. It happens when, as an admin, i try to add a weblog entry into my weblog:

2007-08-08 10:26:00 ERROR Zope.SiteErrorLog http://localhost:51009/[…]/createObject
Traceback (innermost last):
  Module ZPublisher.Publish, line 125, in publish
  Module Zope2.App.startup, line 238, in commit
  Module transaction._manager, line 96, in commit
  Module transaction._transaction, line 395, in commit
  Module transaction._transaction, line 495, in _commitResources
  Module ZODB.Connection, line 510, in commit
  Module ZODB.Connection, line 555, in _commit
  Module ZODB.Connection, line 582, in _store_objects
  Module ZODB.serialize, line 407, in serialize
  Module ZODB.serialize, line 416, in _dump
TypeError: Can't pickle objects in acquisition wrappers.

[1] In WeblogEntry.py, line 147, we have to use a capital "C" for Creators:
return [AuthorTopic(each).__of__(weblog) for each in self.Creators()]
Added by Tom Lazar on Sep 17, 2007 06:56 PM
Issue state: openpostponed
Target release: 1.51.6
i definitely cannot reproduce this bug with current trunk and plone 3.0.1.

can we close this?
Added by Christian Ledermann on Sep 24, 2007 10:07 AM
this only occurs together with plone softwarecenter which adds the getCategories Keyword Index.

I do not know if this is present in the current version too, please check.
Added by Tim Hicks on Sep 24, 2007 02:00 PM
As of 1.6, Quills no longer uses getCategories as it uses getTopics instead. This should no longer be an issue.
Added by Clayton Parker on Feb 16, 2008 05:34 AM
I was still receiving this error on a Plone 3 site I was developing against the Quills trunk (1.6). Here is the fix that ended up working for me:

http://dev.plone.org/collective/changeset/58793
Added by Clayton Parker on Feb 23, 2008 11:56 PM
After talking to tim2p in irc I have retracted the change I made. Turns out I had a catalog index named getAuthors that was trying to index the method on the WeblogEntry. This made the catalog mad because there were items with acquisition wrappers on them being returned.

Basically if you have an index that lines up with one of the methods on a Quills objects that is returning items in acquisition wrappers then you are going to receive this error. While discussing the issue tim2p had some ideas about avoiding this behavior. But he and I both agreed that these solutions would be pretty ugly. So for now just be aware that this **could** happen depending on the indexes created by add-on products or custom products you are developing.

No responses can be added.