Commit 7c6681f0 authored by Tim Peters's avatar Tim Peters

Add new, optional "database-name" key to <zodb> config.

This allows specifying part of what's needed for multidatabases
in a ZODB config file.  More to come.
parent 5510382a
......@@ -176,6 +176,17 @@
Target size, in number of objects, of each version connection's
object cache.
</description>
<key name="database-name" default="unnamed"/>
<description>
When multidatabases are in use, this is the name given to this
database in the collection. The name must be unique across all
databases in the collection. The collection must also be given
a mapping from its databases' names to their databases, but that
cannot be specified in a ZODB config file. Applications using
multidatabases typical supply a way to configure the mapping in
their own config files, using the "databases" parameter of a DB
constructor.
</description>
</sectiontype>
</component>
......@@ -100,7 +100,8 @@ class ZODBDatabase(BaseConfig):
pool_size=section.pool_size,
cache_size=section.cache_size,
version_pool_size=section.version_pool_size,
version_cache_size=section.version_cache_size)
version_cache_size=section.version_cache_size,
database_name=section.database_name)
except:
storage.close()
raise
......
......@@ -151,3 +151,22 @@ Clean up:
>>> for a_db in dbmap.values():
... a_db.close()
The database name can also be specified in a config file, starting in
ZODB 3.6:
>>> from ZODB.config import databaseFromString
>>> config = """
... <zodb>
... <mappingstorage/>
... database-name this_is_the_name
... </zodb>
... """
>>> db = databaseFromString(config)
>>> print db.database_name
this_is_the_name
>>> db.databases.keys()
['this_is_the_name']
>>> db.close()
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment