ZC Buildout recipe for defining a file-storage
Project description
Recipe for setting up a filestorage
This recipe can be used to define a file-storage. It creates a ZConfig file-storage database specification that can be used by other recipes to generate ZConfig configuration files.
This recipe takes an optional path option. If none is given, it creates and uses a subdirectory of the buildout parts directory with the same name as the part.
The recipe records a zconfig option for use by other recipes.
We’ll show a couple of examples, using a dictionary as a simulated buildout object:
>>> import zc.recipe.filestorage >>> buildout = dict( ... buildout = { ... 'directory': '/buildout', ... }, ... db = { ... 'path': 'foo/Main.fs', ... }, ... ) >>> recipe = zc.recipe.filestorage.Recipe( ... buildout, 'db', buildout['db'])>>> print buildout['db']['path'] /buildout/foo/Main.fs>>> print buildout['db']['zconfig'], <zodb> <filestorage> path /buildout/foo/Main.fs </filestorage> </zodb>>>> recipe.install() ()>>> import tempfile >>> d = tempfile.mkdtemp() >>> buildout = dict( ... buildout = { ... 'parts-directory': d, ... }, ... db = {}, ... )>>> recipe = zc.recipe.filestorage.Recipe( ... buildout, 'db', buildout['db'])>>> print buildout['db']['path'] /tmp/tmpQo0DTB/db/Data.fs>>> print buildout['db']['zconfig'], <zodb> <filestorage> path /tmp/tmpQo0DTB/db/Data.fs </filestorage> </zodb>>>> recipe.install() ()>>> import os >>> os.listdir(d) ['db']
The update method doesn’t do much, as the database part’s directory already exists, but it is present, so buildout doesn’t complain and doesn’t accidentally run install() again:
>>> recipe.update()
If the storage’s directory is removed, is it re-added by the update method:
>>> os.rmdir(os.path.join(d, 'db')) >>> os.listdir(d) [] >>> recipe.update() >>> os.listdir(d) ['db']
This is useful in development when the directory containing the database is removed in order to start the database from scratch.
To do
Add support for various file-storage options
Create a ZODB-configuration recipe that is meant to be a base class for storage recipes and provides database-configuration options.
CHANGES
1.1.0 (2008-??-??)
Removed ‘shared-blob-dir’ from blobstorage section.
1.0.0 (2007-11-03)
Initial release.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Hashes for zc.recipe.filestorage-1.0.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 646f1f47c684c6ea4afe5d7ea4fa763a7b0a0159530d796d51312db91f07cd96 |
|
MD5 | d1712c26fd583de4175747108a5c92f2 |
|
BLAKE2b-256 | 850af5243a020b169e55827637fa046ef7a6acfe8584160c7813cb0b9a9ce2d3 |