[Zope-dev] Mountpoints
Jim Fulton
jim at zope.com
Thu Oct 20 07:16:41 EDT 2005
Tim Peters wrote:
> [Chris McDonough]
>
>>There is a wrinkle about performing this merge that eluded my memory
>>until now.
>>
>>To support multidatabases within Zope, it was reasonable to change
>>ZODB.config.ZODBDatabase to support the heretofore
>>likely-unused-by-real-world-code "databases" and "database_name" options
>>that may now be passed into ZODB.DB's constructor:
>>
>>http://svn.zope.org/ZODB/branches/blob-merge-branch/src/ZODB/config.py?rev=38626&r1=38574&r2=38626
>>
>>The current blob-merge-branch code depends on this change being
>>available in the ZODB revision it uses. In case you're interested, the
>>code that actually makes use of this feature in the zodb-blobs-branch is
>>in the Zope2.datatypes.DBTab.getDatabase method.
>>
>>Is this change acceptable for a merge into the ZODB HEAD?
>
>
> Turns out that a release of Zope3 has already been made that supports
> multidatabases, and I'd naturally prefer to follow the lead of a Zope
> that's already out there. Jim showed me the Zope3 implementation code
> and an example today. I found the code easily (on Zope3 trunk), but
> can't for the life of me find anything there that looks like his
> example. Jim, where is that?
Do you mean an example of a zope.conf that uses it?
From a customer engagement:
<zodb main>
<filestorage>
path $DATADIR/Data.fs
</filestorage>
</zodb>
<zodb a>
<filestorage>
path $DATADIR/A.fs
</filestorage>
</zodb>
We decided to use the section names for the database names.
This was to avoid changing ZODB. I'm not sure that that was
a good idea.
This approach has two disadvantages:
- Because section names are case insenstive,
database names end up being lower case, whether we
want them to be or not.
- It may not be obvious that the section name
is also the database name. I'm really unsure about
whether this is a disadvantage. I'm not sure if:
<zodb>
name main
<filestorage>
path $DATADIR/Data.fs
</filestorage>
</zodb>
<zodb>
name a
<filestorage>
path $DATADIR/A.fs
</filestorage>
</zodb>
is better or worse than the first version. I'm inclined to think
that any time you have sections of the same type, it is desireable
to give them names, in which case we might be tempted to list the
names twice.
>
> The Zope3 code in question is in
>
> src/zope/app/appsetup/appsetup.py
>
> function multi_database(). Note that they didn't change any ZODB
> files, instead they give values to a DB's .databases and
> .database_name attributes after constructing the DB. While that might
> be questionable in general <cough>, the implementation of
> multidatabases was meant to be both concrete and public. It's not an
> accident that ZODB's tutorial tests/multidb.txt doctest explains and
> exploits details of the concrete implementation -- it's not meant to
> be abstract. IOW, poking in new values for these attributes isn't
> considered to be evil.
I'd be happy to plumb this through the factories open method. It would
seem to me that we only need to be able to pass a databases argument.
The factory presumably knows it's own name. It could then pass the
databases dict and the name to the DB constructor.
> I believe (here's where the example I can't find would nail it) they
> use the name on a <zodb> section as the DB's database_name. Fred
> points out that ZConfig section names are case-insensitive, forced to
> lowercase, so that
>
> <zodb CHRIS>
>
> and
>
> <zodb cHris>
>
> have the same name. That's not ideal, and threading these attributes
> throughout ZODB's config.py instead (as you did) would be a sane way
> to worm around that.
I haven't looked at Chris's changes. I was pretty happy that the
changes we made in Z3 were fairly localized and small.
> But for right now, I think doing it differently than Zope3 does it
> would cause needless confusion more than it would help. Enhancing
> Zope3 and Zope 2.9 in the same way(s) here could make sense.
OTOH, this feature has hardly been used in Z3. I added to ZODB
because I had been meaning to for some time ad because we needed
it for a customer. I don't think anyone else has used it, so I don't
think there's much established pattern in Z3. Then again, I'm not
sure, except for the case insentitivity issue that we didn't
do it the best way. I'd much rather revisit the case insenstitivity
of section names in ZConfig. I think that if ZConfig section names
were case sensitive or at least case preserving, I'd be happy with
the approach we took.
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