[Zodb-checkins] SVN: ZODB/trunk/src/ New Feature:
Jim Fulton
jim at zope.com
Mon May 17 14:23:26 EDT 2010
Log message for revision 112425:
New Feature:
The filestorage packer configuration option noe accepts calues of
the form ``modname:expression``, allowing the use of packer
factories with options.
Changed:
U ZODB/trunk/src/CHANGES.txt
U ZODB/trunk/src/ZODB/FileStorage/zconfig.txt
U ZODB/trunk/src/ZODB/component.xml
U ZODB/trunk/src/ZODB/config.py
-=-
Modified: ZODB/trunk/src/CHANGES.txt
===================================================================
--- ZODB/trunk/src/CHANGES.txt 2010-05-17 17:54:16 UTC (rev 112424)
+++ ZODB/trunk/src/CHANGES.txt 2010-05-17 18:23:26 UTC (rev 112425)
@@ -41,6 +41,10 @@
index file if an output file name is given via the --output/-o
option.
+- The filestorage packer configuration option noe accepts calues of
+ the form ``modname:expression``, allowing the use of packer
+ factories with options.
+
Bugs Fixed
----------
Modified: ZODB/trunk/src/ZODB/FileStorage/zconfig.txt
===================================================================
--- ZODB/trunk/src/ZODB/FileStorage/zconfig.txt 2010-05-17 17:54:16 UTC (rev 112424)
+++ ZODB/trunk/src/ZODB/FileStorage/zconfig.txt 2010-05-17 18:23:26 UTC (rev 112425)
@@ -134,6 +134,33 @@
>>> fs.close()
+ If the packer contains a ':', then the text after the first ':' is
+ interpreted as an expression. This is handy to pass limited
+ configuration information to the packer:
+
+ >>> def packer_factory(name):
+ ... def packer(storage, referencesf, stop, gc):
+ ... print repr(name), referencesf, storage is fs, gc,
+ ... print storage.pack_keep_old
+ ... return packer
+ >>> ZODB.FileStorage.config_demo_printing_packer_factory = packer_factory
+
+ >>> fs = ZODB.config.storageFromString("""
+ ... <filestorage>
+ ... path my.fs
+ ... packer ZODB.FileStorage:config_demo_printing_packer_factory('bob ')
+ ... </filestorage>
+ ... """)
+
+ >>> import time
+ >>> db = ZODB.DB(fs) # writes object 0
+ >>> fs.pack(time.time(), 42)
+ 'bob ' 42 True True True
+
+ >>> fs.close()
+
+
+
pack-gc
If false, then no garbage collection will be performed when
packing. This can make packing go much faster and can avoid
Modified: ZODB/trunk/src/ZODB/component.xml
===================================================================
--- ZODB/trunk/src/ZODB/component.xml 2010-05-17 17:54:16 UTC (rev 112424)
+++ ZODB/trunk/src/ZODB/component.xml 2010-05-17 18:23:26 UTC (rev 112425)
@@ -44,7 +44,7 @@
raised.
</description>
</key>
- <key name="packer" datatype="dotted-name">
+ <key name="packer" datatype="string">
<description>
The dotted name (dotted module name and object name) of a
packer object. This is used to provide an alternative pack
Modified: ZODB/trunk/src/ZODB/config.py
===================================================================
--- ZODB/trunk/src/ZODB/config.py 2010-05-17 17:54:16 UTC (rev 112424)
+++ ZODB/trunk/src/ZODB/config.py 2010-05-17 18:23:26 UTC (rev 112425)
@@ -158,8 +158,15 @@
config = self.config
options = {}
if getattr(config, 'packer', None):
- m, name = config.packer.rsplit('.', 1)
- options['packer'] = getattr(__import__(m, {}, {}, ['*']), name)
+ packer = config.packer
+ if ':' in packer:
+ m, expr = packer.split(':', 1)
+ m = __import__(m, {}, {}, ['*'])
+ options['packer'] = eval(expr, m.__dict__)
+ else:
+ m, name = config.packer.rsplit('.', 1)
+ m = __import__(m, {}, {}, ['*'])
+ options['packer'] = getattr(m, name)
for name in ('blob_dir', 'create', 'read_only', 'quota', 'pack_gc',
'pack_keep_old'):
More information about the Zodb-checkins
mailing list