[ZODB-Dev] [ zodb-Bugs-225532 ] Persistent __call_method__ interferes with __getstate__

noreply@sourceforge.net noreply@sourceforge.net
Sat, 09 Nov 2002 14:32:10 -0800


Bugs item #225532, was opened at 2000-12-12 14:30
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=115628&aid=225532&group_id=15628

Category: None
Group: None
>Status: Closed
Resolution: None
Priority: 5
Submitted By: John D. Heintz (jheintz)
Assigned to: Nobody/Anonymous (nobody)
Summary: Persistent __call_method__ interferes with __getstate__

Initial Comment:
Using the __call_method__ hook interferes with __getstate__ calls by failing on number of arguments.

The example script has two Persistent classes, T1 and T2.  Both implement a trivial __getstate__() method, but only T2 implements __call_method__.

Given the test file:
#-----------------------------------------------------------------
import ZODB
from Persistence import Persistent
from ZODB import DemoStorage
storage = DemoStorage.DemoStorage()
db = ZODB.DB(storage)


class T1(Persistent):
    def __getstate__(self):
        return Persistent.__getstate__(self)
       
class T2(Persistent):
    def __getstate__(self):
        return Persistent.__getstate__(self)
       
    def __call_method__(self, method, methArgs, kwArgs = {}):
        return apply(method, methArgs, kwArgs)
    
conn = db.open()
root = conn.root()

#This worksfor T1 types
root['t1'] = T1()
get_transaction().commit()

#This doesn't work T2 types
root['t2'] = T2()
get_transaction().commit()

conn.close()
#------------------------------------------------------------

The second get_transaction().commit() will generate the following stack trace:
Traceback (innermost last):
  File "test2.py", line 28, in ?
    get_transaction().commit()
  File "C:\PROGRAMS\ZOPE\lib\python\ZODB\Transaction.py", line 251, in commit
    j.commit(o,self)
  File "C:\Programs\Zope\lib\python\ZODB\Connection.py", line 344, in commit
    state=object.__getstate__()
  File "test2.py", line 17, in __call_method__
    return apply(method, methArgs, kwArgs)
  File "test2.py", line 14, in __getstate__
    return Persistent.__getstate__(self)
  File "test2.py", line 17, in __call_method__
    return apply(method, methArgs, kwArgs)
TypeError: function requires exactly 0 arguments; 1 given

The __setstate__ call also seems to be affected, but I don't have a test case yet for that.


----------------------------------------------------------------------

>Comment By: Guido van Rossum (gvanrossum)
Date: 2002-11-09 17:32

Message:
Logged In: YES 
user_id=6380

I can't reproduce this with ZODB 3.1.

Closing this fure sheer age. If you have problems with ZODB
3.1, please open a new bug report!

----------------------------------------------------------------------

Comment By: John D. Heintz (jheintz)
Date: 2001-01-23 00:00

Message:
I'm adding a patch that fixes this bug.

----------------------------------------------------------------------

Comment By: John D. Heintz (jheintz)
Date: 2000-12-12 14:31

Message:
The indenting got lost.  ;-(

Only the classes are indented.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=115628&aid=225532&group_id=15628