Skip to content

Commit

Permalink
Merge pull request #8 from plone/workaround-to-fix-moved-objects
Browse files Browse the repository at this point in the history
Workaround to fix the path of moved objects
  • Loading branch information
jensens committed May 21, 2019
2 parents ed9d8aa + c66e77c commit ad9f77f
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 1 deletion.
3 changes: 2 additions & 1 deletion five/intid/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,8 @@ Renaming an object should not break the rewrapping of the object:
>>> moved = intid.getObject(ob_id)
>>> moved
<SimpleContent at /test_folder_1_/mycont_new>
>>> [x.path for x in intid.ids]
['/test_folder_1_/mycont_new']

Nor should moving it:

Expand Down Expand Up @@ -361,4 +363,3 @@ Creating items whith a circular containment
...
TypeError: ('Could not adapt', <SimpleItem at c>,
<InterfaceClass zope.keyreference.interfaces.IKeyReference>)

3 changes: 3 additions & 0 deletions five/intid/intid.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,9 @@ def moveIntIdSubscriber(ob, event):
for utility in utilities:
try:
uid = utility.getId(ob)
# XXX this is a temporary workaround
utility.refs.pop(uid, None)
utility.ids.pop(key, None)
utility.refs[uid] = key
utility.ids[key] = uid
except KeyError:
Expand Down
2 changes: 2 additions & 0 deletions five/intid/keyreference.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,11 +132,13 @@ def __call__(self):
return self.wrapped_object

def __hash__(self):
# XXX Maybe we should consider to use also other fields for the hash
return hash((self.dbname,
self.object._p_oid,
))

def __cmp__(self, other):
# XXX This makes no sense on Python 3
if self.key_type_id == other.key_type_id:
return cmp((self.dbname, self.oid), (other.dbname, other.oid))
return cmp(self.key_type_id, other.key_type_id)
1 change: 1 addition & 0 deletions news/8.fixed
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Properly update the persistent objects stored in the initid utility btrees [ale-rt]

0 comments on commit ad9f77f

Please sign in to comment.