On Mon, Jan 14, 2013 at 01:32:07PM -0500, Tres Seaver wrote: > While working on preparation for a Py3k port, I've stumbled across a > fundamental issue with how ZODB structures its API. Do we intend that > client code do the following:: > > from ZDOB import DB, FileStorage > db = DB(FileStorage('/path/to/Data.fs'))
ZODB.FileStorage is a module, you can't call it. ZODB.DB, much to my surprise, refers to the ZODB.DB.DB class. A backwards compatibility thing maybe? > or use the module as a facade :: > > import ZODB > db = ZODB.DB(ZODB.FileStorage.FileStorage('/path/to/Data.fs')) This rings warning bells in my mind: if you're using the ZODB.FileStorage module, you should import it directly: import ZODB import ZODB.FileStorage db = ZODB.DB(ZODB.FileStorage.FileStorage('/path/to/Data.fs')) > I would actually prefer that clients explicitly import the intermediate > modules:: > > from ZDOB import DB, FileStorage > db = DB.DB(FileStorage.FileStorage('/path/to/Data.fs')) (I'm not a fan of this style, but never mind that.) > or even better:: > > from ZDOB.DB import DB > # This one can even be ambiguous now > from ZODB.FileStorage import FileStorage > db = DB(FileStorage('/path/to/Data.fs')) This is what I usually do. I don't get the ambiguous comment. ZODB.DB is (currently) always the class[1]. ZODB.FileStorage is always the module. [1] I think (currently) the only way to refer to the ZODB.DB module is to use sys.modules['ZODB.DB']: >>> import ZODB >>> ZODB.DB <class 'ZODB.DB.DB'> >>> from ZODB import DB >>> DB <class 'ZODB.DB.DB'> >>> import ZODB.DB >>> ZODB.DB <class 'ZODB.DB.DB'> > The driver for the question is getting the tests to pass under both > 'nosetests' and 'setup.py test', where the order of module imports etc. > can make the ambiguous cases problematic. It would be a good time to do > whatever BBB stuff we need to (I would guess figuring out how to emit > deprecation warnings for whichever variants) before releasing 4.0.0. Can you demonstrate the ambiguity? As I've shown before, I was unable to find it, at least with Python 2.x. Marius Gedminas -- We don't really understand it, so we'll give it to the programmers.
signature.asc
Description: Digital signature
_______________________________________________ For more information about ZODB, see http://zodb.org/ ZODB-Dev mailing list - ZODB-Dev@zope.org https://mail.zope.org/mailman/listinfo/zodb-dev