[Zodb-checkins] SVN: ZODB/trunk/src/ZODB/ Add new, optional "database-name" key to <zodb> config.

Tim Peters tim.one at comcast.net
Sun Oct 23 21:59:07 EDT 2005


Log message for revision 39567:
  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.
  

Changed:
  U   ZODB/trunk/src/ZODB/component.xml
  U   ZODB/trunk/src/ZODB/config.py
  U   ZODB/trunk/src/ZODB/tests/multidb.txt

-=-
Modified: ZODB/trunk/src/ZODB/component.xml
===================================================================
--- ZODB/trunk/src/ZODB/component.xml	2005-10-23 18:08:30 UTC (rev 39566)
+++ ZODB/trunk/src/ZODB/component.xml	2005-10-24 01:59:06 UTC (rev 39567)
@@ -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>

Modified: ZODB/trunk/src/ZODB/config.py
===================================================================
--- ZODB/trunk/src/ZODB/config.py	2005-10-23 18:08:30 UTC (rev 39566)
+++ ZODB/trunk/src/ZODB/config.py	2005-10-24 01:59:06 UTC (rev 39567)
@@ -100,7 +100,8 @@
                            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

Modified: ZODB/trunk/src/ZODB/tests/multidb.txt
===================================================================
--- ZODB/trunk/src/ZODB/tests/multidb.txt	2005-10-23 18:08:30 UTC (rev 39566)
+++ ZODB/trunk/src/ZODB/tests/multidb.txt	2005-10-24 01:59:06 UTC (rev 39567)
@@ -151,3 +151,22 @@
 
     >>> 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()
+



More information about the Zodb-checkins mailing list