Thanks Andreas and Dieter,

The explanation was quite simple, I set an attribute on an object that
was a method like this::

class TestBase(ZopeTestCase.ZopeTestCase):

    def dummy_redirect(self, *a, **kw):
        self.has_redirected = a[0]
        if kw:
            print "*** Redirecting to %r + (%s)" % (a[0], kw)
            print "*** Redirecting to %r" % a[0]

    def afterSetUp(self):
        dispatcher = self.folder.manage_addProduct['MExpenses']
        self.mexpenses = self.folder['mexpenses']
        self.mexpenses.http_redirect = self.dummy_redirect # NOTICE!!

        request =
        sdm =
        request.set('SESSION', sdm.getSessionData())

        self.has_redirected = False

The reason for the dummy redirector is boring. The reason for the
transaction.get().commit() is to not cancel everything when a
ConflicrError happens during a very long-lasting file upload.

Again, thanks.

PS. Andreas, I did use your set_trace() tip on the ZODB code. Isn't
Python great!

On 08/01/2008, Dieter Maurer <[EMAIL PROTECTED]> wrote:
> Peter Bengtsson wrote at 2008-1-7 18:29 +0000:
> >My code works fine in normal running zope but not when run as a testcase
> >(I'm not using bin/zopectl test if that matters) I get the following error.
> >I feel guilty since I've got this line in my code:
> >transaction.get().commit()  (
> >
> >I remember having come across this error before but can't remember what
> >the solution was.
> > ...
> >   File "/home/peterbe/zope/zope285/lib/python/ZODB/", line
> >339, in _dump
> >     self._p.dump(state)
> >   File "", line 69, in _reduce_ex
> >     raise TypeError, "can't pickle %s objects" % base.__name__
> >TypeError: can't pickle instancemethod objects
> >
> >----------------------------------------------------------------------
> Apparently, you have an "instancemethod" in your test setup
> where you do not have one in the normal Zope.
> An alternative explanation could be that in your normal
> Zope additional pickle registrations are performed.
> If you would use, e.g., my "CompiledExecutable" product,
> then the import of this product would register "code" and "instancemethod"
> instances as picklable. A test setup may not import "CompiledExecutables"
> and its pickle registrations would be missing.
> A side note: Usually, it is a very bad idea to perform a full
> "commit" in a test. Such "commit"s are incompatible with
> techniques that share (for efficiency reasons) part of the
> test setup among several tests. "ZopeTestCase", e.g., makes
> use of such techniques.
> --
> Dieter

Peter Bengtsson,
Zope maillist  -
**   No cross posts or HTML encoding!  **
(Related lists - )

Reply via email to