[Zope-dev] Re: Converting from old-style BTreess
Jim Fulton
jim at zope.com
Sun Dec 14 22:08:32 EST 2003
Chris McDonough wrote:
> I think this problem is actually easier to solve in the common case than
> requring that people run a conversion script. The ZGlobals data
> structure is a cache, and can be blown away and recreated
> indiscriminately. It's recreated whenever a Product is added or
> removed, and Zope already does this as a matter of course if anything
> about the data structure is goofy.
Hm, OK. Then the question is how to decide that it's goofy.
I'll note that I certainly did not intend it to be a cache when
I added it a long time ago. I'm a bit uncomfortable assuming that
it's always used that way, but you know more than I about the current usage.
> I think the problem Sidnei has run into isn't so much that the BTree
> module can't be imported, it's instead that the
> Persistence.PersistentMapping module redefines PersistentMapping in
> order to do something I don't quite understand, and the redefinition is
> what appears to be causing the AttributeError, 'data' to appear.
Hm, I'll add a comment explaining what's going on.
> If
> it's not used, everything works fine. Here's the module:
>
> import Persistence
> import persistent
> from persistent.mapping import PersistentMapping
>
> if Persistence.Persistent is not persistent.Persistent:
> class PersistentMapping(Persistence.Persistent, PersistentMapping):
> """Legacy persistent mapping class
>
> This class mixes in ExtensionClass Base if it is present.
>
> Unless you actually want ExtensionClass semantics, use
> persistent.mapping.PersistentMapping instead.
> """
>
> If you comment out the "if" clause and everything underneath of it, make
> a dummy BTree.py module with the following and put in in the software
> home:
>
> from Globals import Persistent
>
> class BTree(Persistent):
> pass
>
> ... and restart Zope with an "old" filestorage file, all is well:
There needs to be a cleaner solution than this. A Dummy BTree module is
not acceptable.
...
> I'm not sure what the redefinition is supposed to achieve?
persistent.Persistent is not an extension class. It's a pure
new-style persistent base class.
Persistent.Persistent is an extension class if ExtensionClass is
installed. If ExtensionClass is not installed, then a warning is issued and
it is set tp persistent.Persistent. This is to ease the transition for
people who use ZODB outside of Zope.
The check above is to cause an extension-class-based PersistentMapping
is ExtensionClass is installed.
Jim
--
Jim Fulton mailto:jim at zope.com Python Powered!
CTO (540) 361-1714 http://www.python.org
Zope Corporation http://www.zope.com http://www.zope.org
More information about the Zope-Dev
mailing list