Re: Objects with varying classes
Jason Madden <[email protected]> Wed, 26 Sep 2018 07:42:36 -0700 (PDT)
| Newsgroups | gmane.comp.web.zope.zodb |
|---|---|
| Message-ID | <[email protected]> |
In general, the only way to change the `__class__` of a Persistent object is to update *all* references to it. For references in a BTree, that may mean updating the tree itself (if small) or the individual bucket. There's further discussion of this here: https://github.com/zopefoundation/BTrees/issues/72 Because finding and changing all references is usually difficult (even one missed reference can break everything), this is not usually recommended for applications (migration tools can be written to do this by crawling through the entire database object-by-object, but that's rarely practical for an application). This is one way that interfaces can be more useful than classes: dynamically changing the interfaces an object provides with `interface.alsoProvides(object, IFoo)` or `interface.noLongerProvides(object, IFoo)` propagates automatically to all references to the object. HTH, Jason -- You received this message because you are subscribed to the Google Groups "zodb" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.