Commit 308a53f9 authored by Jim Fulton's avatar Jim Fulton

New Feature:

  The filestorage packer configuration option noe accepts calues of
  the form ``modname:expression``, allowing the use of packer
  factories with options.
parent 386750b2
......@@ -41,6 +41,10 @@ New Features
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
----------
......
......@@ -134,6 +134,33 @@ packer
>>> 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
......
......@@ -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
......
......@@ -158,8 +158,15 @@ class FileStorage(BaseConfig):
config = self.config
options = {}
if getattr(config, 'packer', None):
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)
options['packer'] = getattr(__import__(m, {}, {}, ['*']), name)
m = __import__(m, {}, {}, ['*'])
options['packer'] = getattr(m, name)
for name in ('blob_dir', 'create', 'read_only', 'quota', 'pack_gc',
'pack_keep_old'):
......
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