Recipe to configure File System Storage
Project description
Supported options
The recipe supports the following options:
- conf
Filesystem path for the configuration file. Need the complete path to the file.
- zope-instances
List of filesystem paths for standalone zope instances or ZEO client instances. One path by line.
- storages
List of FSS configurations for your buildout. The first line is for the global configuration. Following lines are by zope path specific configurations.
- Each line is build on the below model:
name zope_path fss_strategy storage_filesystem_path backup_filesystem_path
The two first parameters are required. Others are needed sequentially: if you need to define storage_filesystem_path you have to define fss_strategy. It’s a space based configuration: don’t use spaces in parameters.
- name
a name for these part of the configuration
- zope_path
an absolute path in the ZODB
- fss_strategy (optional)
a strategy between directory (default), flat, site1 and site2
- storage_filesystem_path (optional)
filesystem path where active files are stored. Default path is $buildout_path/var/fss_storage_$name
- backup_filesystem_path (optional)
filesystem path where files backup are stored. Default path is $buildout_path/var/fss_backup_$name
Example:
[fss] recipe = iw.recipe.fss ## Deprecated #conf = ${zopeinstance:location}/etc/plone-filesystemstorage.conf # Replacement for 'conf' option zope-instances = ${zeoclient1:location} ${zeoclient2:location} storages = # The first is always generic global / # Others are always specific pone_flat /site flat /somewhere/files /somewhere/files_backup
Example usage
The recipe is called by buildout, let’s create an instance of it, with a buildout simulated context:
>>> from zc.buildout.testing import * >>> import os; join = os.path.join >>> data_dir = join(test_dir, 'data') >>> data2_dir = join(test_dir, 'data2') >>> bin_dir = join(data_dir, 'bin') >>> var_dir = join(data_dir, 'var2') >>> conf_dir = join(data_dir, 'etc') >>> conf2_dir = join(data2_dir, 'etc') >>> buildout = {'zeoclient1': {'location': data_dir}, ... 'zeoclient2': {'location': data2_dir}, ... 'buildout': {'bin-directory': bin_dir}} >>> name = 'fss' >>> options = {'zope-instances': ''' ... %(zeoclient1_location)s ... %(zeoclient2_location)s ... ''' % {'zeoclient1_location': data_dir, 'zeoclient2_location': data2_dir}, ... 'storages': """ ... global / ... storage2 /site/storage2 flat ... storage3 /site/storage3 flat %(var)s/storage ... storage4 /site/storage4 flat %(var)s/sub/storage %(var)s/sub/backup ... """ % {'var': var_dir}}
Creating the recipe:
>>> from iw.recipe.fss import Recipe >>> recipe = Recipe(buildout, name, options)
Running it:
>>> paths = list(recipe.install())
Checking files created. We don’t want this recipe to list the created dir, so in case of uninstallation, they are never removed:
>>> paths.sort() >>> paths ['...data/etc/plone-filesystemstorage.conf', '...data2/etc/plone-filesystemstorage.conf']
Checking the conf file:
>>> conf = open(join(conf_dir, ... 'plone-filesystemstorage.conf')) >>> print conf.read() # FSS conf file generated by iw.recipe.fss <BLANKLINE> # main storage global for / storage-path /.../data/var/fss_storage_global backup-path /.../data/var/fss_backup_global storage-strategy directory <BLANKLINE> # storage storage2 <site /site/storage2> storage-path /.../data/var/fss_storage_storage2 backup-path /.../data/var/fss_backup_storage2 storage-strategy flat </site> <BLANKLINE> # storage storage3 <site /site/storage3> storage-path /.../data/var2/storage backup-path /.../data/var/fss_backup_storage3 storage-strategy flat </site> <BLANKLINE> # storage storage4 <site /site/storage4> storage-path /.../sub/storage backup-path /.../sub/backup storage-strategy flat </site> <BLANKLINE> <BLANKLINE>
Checking the conf file:
>>> conf = open(join(conf2_dir, ... 'plone-filesystemstorage.conf')) >>> print conf.read() # FSS conf file generated by iw.recipe.fss <BLANKLINE> # main storage global for / storage-path /.../data/var/fss_storage_global backup-path /.../data/var/fss_backup_global storage-strategy directory <BLANKLINE> # storage storage2 <site /site/storage2> storage-path /.../data/var/fss_storage_storage2 backup-path /.../data/var/fss_backup_storage2 storage-strategy flat </site> <BLANKLINE> # storage storage3 <site /site/storage3> storage-path /.../data/var2/storage backup-path /.../data/var/fss_backup_storage3 storage-strategy flat </site> <BLANKLINE> # storage storage4 <site /site/storage4> storage-path /.../sub/storage backup-path /.../sub/backup storage-strategy flat </site> <BLANKLINE> <BLANKLINE>
Existing data
Let’s fill the data folder with data:
>>> storage_dir = join(var_dir, 'storage') >>> data = 'xxxx' >>> f = open(join(storage_dir, 'data'), 'w') >>> f.write(data) >>> f.close() >>> ls(storage_dir) - data
Let’s re-run the recipe:
>>> paths = list(recipe.install())
Let’s make sure that no existing path was returned by the recipe, otherwise zc.buildout might treat them as new files. The only new file we should get is the conf file because it’s the only one that is re-written everytime:
>>> paths ['...plone-filesystemstorage.conf']
We shouldn’t loose the data:
>>> ls(storage_dir) - data >>> for path in paths: ... try: ... os.rmdir(path) ... except: ... os.remove(path)
Alternate configurations
Try with conf option:
>>> buildout = {'instance': {'location': data_dir}, ... 'buildout': {'bin-directory': bin_dir}} >>> name = 'fss' >>> options = {'conf': join(conf_dir, ... 'plone-filesystemstorage.conf'), ... 'storages': """ ... global / ... storage2 /site/storage2 flat ... """ % {'var': var_dir}} >>> recipe = Recipe(buildout, name, options) >>> paths = list(recipe.install())
Checking the conf file:
>>> conf = open(join(conf_dir, ... 'plone-filesystemstorage.conf')) >>> print conf.read() # FSS conf file generated by iw.recipe.fss <BLANKLINE> # main storage global for / storage-path /.../data/var/fss_storage_global backup-path /.../data/var/fss_backup_global storage-strategy directory <BLANKLINE> # storage storage2 <site /site/storage2> storage-path /.../data/var/fss_storage_storage2 backup-path /.../data/var/fss_backup_storage2 storage-strategy flat </site> <BLANKLINE>
Try without conf nor zope-instances option:
>>> buildout = {'instance': {'location': data_dir}, ... 'buildout': {'bin-directory': bin_dir}} >>> name = 'fss' >>> options = {'storages': """ ... global / ... storage2 /site/storage2 flat ... """ % {'var': var_dir}} >>> recipe = Recipe(buildout, name, options) >>> paths = list(recipe.install())
Checking the conf file:
>>> conf = open(join(conf_dir, ... 'plone-filesystemstorage.conf')) >>> print conf.read() # FSS conf file generated by iw.recipe.fss <BLANKLINE> # main storage global for / storage-path /.../data/var/fss_storage_global backup-path /.../data/var/fss_backup_global storage-strategy directory <BLANKLINE> # storage storage2 <site /site/storage2> storage-path /.../data/var/fss_storage_storage2 backup-path /.../data/var/fss_backup_storage2 storage-strategy flat </site> <BLANKLINE>
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
Built Distribution
File details
Details for the file iw.recipe.fss-0.2.1.tar.gz
.
File metadata
- Download URL: iw.recipe.fss-0.2.1.tar.gz
- Upload date:
- Size: 8.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 522d0d81165186c7776a79b85a7dbb7e5d8b888e500e4f106eb8e26eee25b07d |
|
MD5 | b1bc8831b8edaa26e28ad8ac4265b6ba |
|
BLAKE2b-256 | ac078901b40b4fd803bf5efcac20ad78dc2233bbede9d4422fcd7f0fa51ce379 |
File details
Details for the file iw.recipe.fss-0.2.1-py2.4.egg
.
File metadata
- Download URL: iw.recipe.fss-0.2.1-py2.4.egg
- Upload date:
- Size: 13.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7b0578b2cecc9fd9ba672f5f530cefaaf38d789ab31a318fae764e997d363f87 |
|
MD5 | 741f9fdbcf46c1ececf4890138bf4bea |
|
BLAKE2b-256 | 49d2c75343b249784e37832f456d6f3e0442a0dca8cfaa42275e842e30c20b89 |