[TransWarp] problem with commit and activated query-link

Ulrich Eck ueck at net-labs.de
Tue Feb 18 07:06:39 EST 2003


again it's me:

when i access the "folders" property of a folder before i add new
ones, i get an error on commit:
(i.o.w: when i access the Querylink and then change values the error happens)

>>> from peak.api import *
>>> from acmgr.api import *
>>>
>>> class TestServer(connection.IMAPServer):
...     connection = binding.bindTo('imap://jack-e:[email protected]')
...
>>> s = TestServer()
>>>
>>> storage.begin(s)
>>>
>>> f = s.folderDM[('INBOX',)]
>>>
>>> f.folders
[<acmgr.connection.imapmodel.IMAPFolder object at 0x835e2ac>, <acmgr.connection.imapmodel.IMAPFolder object at 
0x835e43c>, <acmgr.connection.imapmodel.IMAPFolder object at 0x835e504>, <acmgr.connection.imapmodel.IMAPFolder object 
at 0x835e5cc>, <acmgr.connection.imapmodel.IMAPFolder object at 0x835e694>, <acmgr.connection.imapmodel.IMAPFolder 
object at 0x835e824>, <acmgr.connection.imapmodel.IMAPFolder object at 0x835e8ec>]
>>>
>>> f1 = s.folderDM.newItem()
>>> f1.name = 'testing'
>>> f.addFolders(f1)
>>> f2 = s.folderDM.newItem()
>>> f2.name = 'sub01'
>>> f1.addFolders(f2)
>>> f3 = s.folderDM.newItem()
>>> f3.name = 'subsub01'
>>> f2.addFolders(f3)
>>>
>>> storage.commit(s)
_new INBOX.testing
_save: INBOX.testing
_new INBOX.testing.sub01
_save: INBOX.testing.sub01
_save: INBOX
_new INBOX.testing.sub01.subsub01
_save: INBOX.testing.sub01.subsub01
_save: INBOX.testing
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "/usr/lib/python2.2/site-packages/peak/storage/transactions.py", line 20, in commitTransaction
    getTransaction(subject).commit()
  File "/usr/lib/python2.2/site-packages/peak/storage/transactions.py", line 223, in commit
    self._prepare()
  File "/usr/lib/python2.2/site-packages/peak/storage/transactions.py", line 183, in _prepare
    unready = [p for p in state.participants if not p.readyToVote(self)]
  File "/usr/lib/python2.2/site-packages/peak/storage/data_managers.py", line 498, in readyToVote
    self.flush()
  File "/usr/lib/python2.2/site-packages/peak/storage/data_managers.py", line 444, in flush
    del dirty[key]
KeyError: 137744044

this probably happens because flush is called when oidFor and readyToVote is called.
the flush in oidFor already clears the dirty-flag, and the flush in readyToVote seems
not to get this right (dirty.values() seem to do something wrong in this case).

would a simple condition in flush():

if key in dirty:
  del dirty[key]

solve the problem (objects might have been saved twice in this case)
or is it a problem with my implementation?


Ulrich Eck
------------------------------------------------------------------------
net-labs Systemhaus GmbH
Ebersberger Str. 46
85570 Markt Schwaben
fon:   +49-8121-4747-11
fax:   +49-8121-4747-77
email: ueck at net-labs.de
http://www.net-labs.de




More information about the PEAK mailing list