-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Incongruence possibility between ghosted class and pickled class metadata #72
Comments
It's not just BTrees, it's any reference to the object. References to persisted objects all include the type so that they can be unghosted: >>> from ZODB import DB, MappingStorage
>>> from persistent import Persistent
>>> import transaction
>>> db = DB(MappingStorage.MappingStorage())
>>> class X(Persistent): pass
>>> class Y(Persistent): pass
>>> x = X()
>>> conn = db.open()
>>> conn.root()['x'] = x
>>> transaction.commit()
>>> x.__class__ = Y
>>> type(x)
__main__.Y
>>> x._p_changed = True
>>> transaction.commit()
>>> conn.root()['x']
<__main__.Y at 0x10d3c18c0>
>>> new_conn = db.open()
>>> new_conn.root()['x']
<__main__.X at 0x10d3c9f50> In general you can't change the This is documented here:
|
I have tried to devise a "fix" here: Not sure if it's a good thing. |
We successfully used an approach described in the fourdigits blog. |
If an object's class attribute is changed, then it won't be correctly unghostified from a retrieval via B-tree since the class is baked into the bucket contents (as an optimization).
Perhaps a solution would be to listen to a commit event for objects loaded through a B-tree and fix-up any buckets if necessary.
The text was updated successfully, but these errors were encountered: