本食谱有助于创建和管理多个Zope 2文件存储。
项目描述
详细文档
介绍
此食谱向由plone.recipe.zope2instance和plone.recipe.[zope2]zeoserver食谱生成的zope.conf和zeo.conf文件添加了额外的文件存储和zodb_db段落。它还创建了将创建额外文件存储数据文件的目录。这使得向Zope 2实例添加额外的文件存储和挂载点变得容易。
支持选项
- parts
要生成的文件存储子部分列表,每行一个。(这与buildout部分不同。)
- zeo
要添加额外文件存储的plone.recipe.zope2zeoserver或plone.recipe.zeoserver部分的名称。默认情况下,如果有,则为构建out中的第一个此类部分。
- zopes
要添加额外文件存储的 plone.recipe.zope2instance 部分名称列表。默认为所有连接到相关 zeoserver 部分的 plone.recipe.zope2instance 部分,如果未找到 ZEO,则为所有 plone.recipe.zope2instance 部分。
以下选项影响生成的 zope.conf 和 zeo.conf。每个选项都可以为 collective.recipe.filestorage buildout 部分的所有文件存储子部分指定,或通过在名为“filestorage_subpart”的新 buildout 部分中放置选项来为特定文件存储子部分指定,其中子部分是该配方“parts”选项中列出的子部分名称。子部分名称可以使用“%(fs_part_name)s”进行插值。
- 位置
Data.fs 文件的位置,相对于 buildout 根目录。默认为 var/filestorage/%(fs_part_name)s/Data.fs
- zodb-name
ZODB 的名称。默认为‘%(fs_part_name)s’。
- zodb-cache-size
设置 ZODB 缓存大小,即 ZODB 缓存将尝试保留的对象数量。从相关的 zope 部分继承。默认为 5000。
- zodb-mountpoint
设置挂载点的路径。默认为‘/%(fs_part_name)s’。
- zodb-container-class
设置被挂载的对象的类。默认未设置。
- zeo-address
设置相关 ZEO 服务器的端口号。从相关的 Zope 和 ZEO 部分继承。默认为 8100。
- zeo-client-cache-size
设置 ZEO 客户端缓存的大小。从相关的 Zope 部分继承。默认为‘30MB’。
- zeo-storage
设置 ZEO 存储的 id。默认为‘%(fs_part_name)s’。
- zeo-client-name
设置 ZEO 客户端的名称。默认为‘%(fs_part_name)s_zeostorage’。
- zeo-client-client
设置用于构造缓存文件名的持久缓存名称。默认禁用持久缓存文件。
- blob-storage
设置用于存储独立 Zope 实例或 ZEO 服务器 blob 的目录。可选。如果打算存储 blob,则必须指定。推荐值:var/blobstorage-%(fs_part_name)s
- zeo-blob-storage
设置用于存储 ZEO 客户端 blob 的目录。默认使用与 blob-storage 相同的值。
- zeo-shared-blob-dir
如果 blob 目录由 ZEO 服务器和客户端共享,则布尔值应为“on”。默认为“on”。
示例用法
让我们创建并运行一个添加额外文件存储的最小 buildout
>>> write('buildout.cfg',
... '''
... [buildout]
... extends = base.cfg
... parts =
... filestorage
... instance
...
... [instance]
... recipe = plone.recipe.zope2instance
... zope2-location = %(zope2_location)s
... user = me
...
... [filestorage]
... recipe = collective.recipe.filestorage
... parts =
... my-fs
... ''' % globals())
>>> print system(join('bin', 'buildout') + ' -q')
我们的 zope.conf 应该会自动将额外的文件存储段注入其中
>>> instance = os.path.join(sample_buildout, 'parts', 'instance')
>>> print open(os.path.join(instance, 'etc', 'zope.conf')).read()
%define INSTANCEHOME...instance
...
<BLANKLINE>
<zodb_db my-fs>
cache-size 5000
<filestorage >
path .../var/filestorage/my-fs/my-fs.fs
</filestorage>
mount-point /my-fs
</zodb_db>
<BLANKLINE>
配方还会为新的文件存储创建一个目录
>>> 'my-fs' in os.listdir(os.path.join(sample_buildout, 'var', 'filestorage')) True
让我们确保每次更改文件存储部分时都会重新生成配置文件,即使 zope/zeo 部分的直接配置没有更改
>>> open('buildout.cfg', 'a').write(" my-fs-2\n")
>>> print system(join('bin', 'buildout') + ' -q')
>>> 'my-fs-2' in open('parts/instance/etc/zope.conf').read()
True
让我们确保即使从 buildout 中删除文件存储部分,文件存储目录也不会被覆盖
>>> write('buildout.cfg',
... '''
... [buildout]
... extends = base.cfg
... parts =
... instance
...
... [instance]
... recipe = plone.recipe.zope2instance
... zope2-location = %(zope2_location)s
... user = me
... ''' % globals())
>>> print system(join('bin', 'buildout') + ' -q')
>>> 'my-fs' in os.listdir(os.path.join(sample_buildout, 'var', 'filestorage'))
True
我们可以覆盖许多设置的默认值
>>> write('buildout.cfg',
... '''
... [buildout]
... extends = base.cfg
... parts =
... filestorage
... instance
...
... [instance]
... recipe = plone.recipe.zope2instance
... zope2-location = %(zope2_location)s
... user = me
...
... [filestorage]
... recipe = collective.recipe.filestorage
... location = var/filestorage/%(fs_part_name)s/Data.fs
... blob-storage = var/blobstorage-%(fs_part_name)s
... zodb-name = %(fs_part_name)s_db
... zodb-cache-size = 1000
... zodb-mountpoint = /%(fs_part_name)s_mountpoint
... zodb-container-class = Products.ATContentTypes.content.folder.ATFolder
... parts =
... my-fs
... '''.replace('%(zope2_location)s', zope2_location))
>>> print system(join('bin', 'buildout') + ' -q')
>>> instance = os.path.join(sample_buildout, 'parts', 'instance')
>>> print open(os.path.join(instance, 'etc', 'zope.conf')).read()
%define INSTANCEHOME...instance
...
<BLANKLINE>
<zodb_db my-fs_db>
cache-size 1000
<blobstorage >
blob-dir .../var/blobstorage-my-fs
<filestorage >
path .../var/filestorage/my-fs/Data.fs
</filestorage>
</blobstorage>
mount-point /my-fs_mountpoint
container-class Products.ATContentTypes.content.folder.ATFolder
</zodb_db>
<BLANKLINE>
也可以通过创建一个带有 filestorage_ 前缀的新部分,仅针对特定文件存储修改设置
>>> write('buildout.cfg',
... '''
... [buildout]
... extends = base.cfg
... parts =
... filestorage
... instance
...
... [instance]
... recipe = plone.recipe.zope2instance
... zope2-location = %(zope2_location)s
... user = me
...
... [filestorage]
... recipe = collective.recipe.filestorage
... parts =
... my-fs
...
... [filestorage_my-fs]
... zodb-cache-size = 1000
... ''' % globals())
>>> print system(join('bin', 'buildout') + ' -q')
>>> instance = os.path.join(sample_buildout, 'parts', 'instance')
>>> print open(os.path.join(instance, 'etc', 'zope.conf')).read()
%define INSTANCEHOME...instance
...
<BLANKLINE>
<zodb_db my-fs>
cache-size 1000
<filestorage >
path .../var/filestorage/my-fs/my-fs.fs
</filestorage>
mount-point /my-fs
</zodb_db>
<BLANKLINE>
默认情况下,该配方将额外的文件存储添加到 buildout 中的每个 plone.recipe.zope2instance 部分,但您可以指定仅将其添加到某些部分
>>> write('buildout.cfg',
... '''
... [buildout]
... extends = base.cfg
... parts =
... filestorage
... instance1
... instance2
...
... [instance1]
... recipe = plone.recipe.zope2instance
... zope2-location = %(zope2_location)s
... user = me
...
... [instance2]
... recipe = plone.recipe.zope2instance
... zope2-location = %(zope2_location)s
... user = me
...
... [filestorage]
... recipe = collective.recipe.filestorage
... zopes = instance1
... parts =
... my-fs
... ''' % globals())
>>> print system(join('bin', 'buildout') + ' -q')
>>> 'my-fs' in open('parts/instance1/etc/zope.conf').read()
True
>>> 'my-fs' in open('parts/instance2/etc/zope.conf').read()
False
与 ZEO 一起使用的示例用法
这是一个包括 ZEO 服务器和两个 ZODB 客户端的最小 buildout
>>> write('buildout.cfg',
... '''
... [buildout]
... extends = base.cfg
... parts =
... filestorage
... zeoserver
... primary
... secondary
...
... [zeoserver]
... recipe = plone.recipe.zope2zeoserver
... zope2-location = %(zope2_location)s
...
... [primary]
... recipe = plone.recipe.zope2instance
... zope2-location = %(zope2_location)s
... user = me
... zeo-client = 1
...
... [secondary]
... recipe = plone.recipe.zope2instance
... zope2-location = %(zope2_location)s
... user = me
... zeo-client = 1
...
... [filestorage]
... recipe = collective.recipe.filestorage
... parts =
... my-fs
... ''' % globals())
>>> print system(join('bin', 'buildout') + ' -q')
这应该在 zeo.conf 和两个 zope.conf 中添加适当的条目
>>> zeoserver = os.path.join(sample_buildout, 'parts', 'zeoserver')
>>> print open(os.path.join(zeoserver, 'etc', 'zeo.conf')).read()
%define INSTANCE /sample-buildout/parts/zeoserver
...
<BLANKLINE>
<filestorage my-fs>
path /sample-buildout/var/filestorage/my-fs/my-fs.fs
</filestorage>
<BLANKLINE>
>>> primary = os.path.join(sample_buildout, 'parts', 'primary')
>>> print open(os.path.join(primary, 'etc', 'zope.conf')).read()
%define INSTANCEHOME /sample-buildout/parts/primary
...
<BLANKLINE>
<zodb_db my-fs>
cache-size 5000
<zeoclient>
server 8100
storage my-fs
name my-fs_zeostorage
var /sample-buildout/parts/primary/var
cache-size 30MB
<BLANKLINE>
</zeoclient>
mount-point /my-fs
</zodb_db>
<BLANKLINE>
>>> secondary = os.path.join(sample_buildout, 'parts', 'secondary')
>>> print open(os.path.join(secondary, 'etc', 'zope.conf')).read()
%define INSTANCEHOME /sample-buildout/parts/secondary
...
<BLANKLINE>
<zodb_db my-fs>
cache-size 5000
<zeoclient>
server 8100
storage my-fs
name my-fs_zeostorage
var /sample-buildout/parts/secondary/var
cache-size 30MB
<BLANKLINE>
</zeoclient>
mount-point /my-fs
</zodb_db>
<BLANKLINE>
如上所述,我们可以覆盖许多默认参数
>>> write('buildout.cfg',
... '''
... [buildout]
... extends = base.cfg
... parts =
... filestorage
... zeoserver
... primary
... secondary
...
... [zeoserver]
... recipe = plone.recipe.zope2zeoserver
... zope2-location = %(zope2_location)s
...
... [primary]
... recipe = plone.recipe.zope2instance
... zope2-location = %(zope2_location)s
... user = me
... zeo-client = 1
...
... [secondary]
... recipe = plone.recipe.zope2instance
... zope2-location = %(zope2_location)s
... user = me
... zeo-client = 1
...
... [filestorage]
... recipe = collective.recipe.filestorage
... location = var/filestorage/%(fs_part_name)s/Data.fs
... blob-storage = var/blobstorage-%(fs_part_name)s
... zodb-cache-size = 1000
... zodb-name = %(fs_part_name)s_db
... zodb-mountpoint = /%(fs_part_name)s_mountpoint
... zeo-address = 8101
... zeo-client-cache-size = 50MB
... zeo-storage = %(fs_part_name)s_storage
... zeo-client-name = %(fs_part_name)s_zeostorage_name
... parts =
... my-fs
... '''.replace('%(zope2_location)s', zope2_location))
>>> print system(join('bin', 'buildout') + ' -q')
>>> zeoserver = os.path.join(sample_buildout, 'parts', 'zeoserver')
>>> print open(os.path.join(zeoserver, 'etc', 'zeo.conf')).read()
%define INSTANCE /sample-buildout/parts/zeoserver
...
<BLANKLINE>
<blobstorage my-fs_storage>
blob-dir /sample-buildout/var/blobstorage-my-fs
<filestorage my-fs_storage>
path /sample-buildout/var/filestorage/my-fs/Data.fs
</filestorage>
</blobstorage>
<BLANKLINE>
>>> primary = os.path.join(sample_buildout, 'parts', 'primary')
>>> print open(os.path.join(primary, 'etc', 'zope.conf')).read()
%define INSTANCEHOME /sample-buildout/parts/primary
...
<BLANKLINE>
<zodb_db my-fs_db>
cache-size 1000
<zeoclient>
blob-dir /sample-buildout/var/blobstorage-my-fs
shared-blob-dir on
server 8101
storage my-fs_storage
name my-fs_zeostorage_name
var /sample-buildout/parts/primary/var
cache-size 50MB
<BLANKLINE>
</zeoclient>
mount-point /my-fs_mountpoint
</zodb_db>
<BLANKLINE>
>>> secondary = os.path.join(sample_buildout, 'parts', 'secondary')
>>> print open(os.path.join(secondary, 'etc', 'zope.conf')).read()
%define INSTANCEHOME /sample-buildout/parts/secondary
...
<BLANKLINE>
<zodb_db my-fs_db>
cache-size 1000
<zeoclient>
blob-dir /sample-buildout/var/blobstorage-my-fs
shared-blob-dir on
server 8101
storage my-fs_storage
name my-fs_zeostorage_name
var /sample-buildout/parts/secondary/var
cache-size 50MB
<BLANKLINE>
</zeoclient>
mount-point /my-fs_mountpoint
</zodb_db>
<BLANKLINE>
默认情况下,该配方将额外的文件存储添加到 buildout 中第一个 plone.recipe.zope2zeoserver 部分,并且如果使用此配方有多个部分,则会引发错误。但是,您可以指定特定的 ZEO 部分,在这种情况下,默认情况下文件存储仅添加到使用该 ZEO 的 Zope
>>> write('buildout.cfg',
... '''
... [buildout]
... extends = base.cfg
... parts =
... filestorage
... zeoserver1
... zeoserver2
... primary
... secondary
... other-zope
...
... [zeoserver1]
... recipe = plone.recipe.zope2zeoserver
... zope2-location = %(zope2_location)s
... zeo-address = 8100
...
... [zeoserver2]
... recipe = plone.recipe.zope2zeoserver
... zope2-location = %(zope2_location)s
... zeo-address = 8101
...
... [primary]
... recipe = plone.recipe.zope2instance
... zope2-location = %(zope2_location)s
... user = me
... zeo-client = 1
... zeo-address = 8101
...
... [secondary]
... recipe = plone.recipe.zope2instance
... zope2-location = %(zope2_location)s
... user = me
... zeo-client = 1
... zeo-address = 8101
...
... [other-zope]
... recipe = plone.recipe.zope2instance
... zope2-location = %(zope2_location)s
... user = me
... zeo-client = 1
... zeo-address = 8100
...
... [filestorage]
... recipe = collective.recipe.filestorage
... zeo = zeoserver2
... parts =
... my-fs
... ''' % globals())
>>> print system(join('bin', 'buildout') + ' -q')
>>> 'my-fs' in open('parts/zeoserver2/etc/zeo.conf').read()
True
>>> 'my-fs' in open('parts/zeoserver1/etc/zeo.conf').read()
False
>>> 'my-fs' in open('parts/primary/etc/zope.conf').read()
True
>>> 'my-fs' in open('parts/other-zope/etc/zope.conf').read()
False
错误条件
重要说明:您必须在添加文件存储的实例和zeoservers部分之前,使用collective.recipe.filestorage配方放置所有部件。否则,您将遇到错误。
>>> write('buildout.cfg',
... '''
... [buildout]
... extends = base.cfg
... parts =
... instance
... filestorage
...
... [instance]
... recipe = plone.recipe.zope2instance
... zope2-location = %(zope2_location)s
...
... [filestorage]
... recipe = collective.recipe.filestorage
... parts =
... my-fs
... ''' % globals())
>>> print system(join('bin', 'buildout') + ' -q')
While:
...
Error: [collective.recipe.filestorage] The "filestorage" part must be listed before the following parts in ${buildout:parts}: instance
<BLANKLINE>
如果没有明确指定要关联的ZEO,使用多个zeoserver部件的buildout将导致错误。
>>> write('buildout.cfg',
... '''
... [buildout]
... extends = base.cfg
... parts =
... filestorage
... zeoserver1
... zeoserver2
... primary
... secondary
...
... [zeoserver1]
... recipe = plone.recipe.zope2zeoserver
... zope2-location = %(zope2_location)s
...
... [zeoserver2]
... recipe = plone.recipe.zope2zeoserver
... zope2-location = %(zope2_location)s
...
... [primary]
... recipe = plone.recipe.zope2instance
... zope2-location = %(zope2_location)s
... user = me
... zeo-client = 1
...
... [secondary]
... recipe = plone.recipe.zope2instance
... zope2-location = %(zope2_location)s
... user = me
... zeo-client = 1
...
... [filestorage]
... recipe = collective.recipe.filestorage
... parts =
... my-fs
... ''' % globals())
>>> print system(join('bin', 'buildout') + ' -q')
While:
...
Error: [collective.recipe.filestorage] "filestorage" part found multiple zeoserver parts; please specify which one to use with the "zeo" option.
指定不存在的zeo应该导致错误。
>>> write('buildout.cfg',
... '''
... [buildout]
... extends = base.cfg
... parts =
... filestorage
... zeoserver
... primary
...
... [zeoserver]
... recipe = plone.recipe.zope2zeoserver
... zope2-location = %(zope2_location)s
...
... [primary]
... recipe = plone.recipe.zope2instance
... zope2-location = %(zope2_location)s
... user = me
... zeo-client = 1
...
... [filestorage]
... recipe = collective.recipe.filestorage
... zeo = foobar
... parts =
... my-fs
... ''' % globals())
>>> print system(join('bin', 'buildout') + ' -q')
While:
...
Error: [collective.recipe.filestorage] "filestorage" part specifies nonexistant zeo part "foobar".
指定不存在的zope部件也应该如此。
>>> write('buildout.cfg',
... '''
... [buildout]
... extends = base.cfg
... parts =
... filestorage
... zeoserver
... primary
...
... [zeoserver]
... recipe = plone.recipe.zope2zeoserver
... zope2-location = %(zope2_location)s
...
... [primary]
... recipe = plone.recipe.zope2instance
... zope2-location = %(zope2_location)s
... user = me
... zeo-client = 1
...
... [filestorage]
... recipe = collective.recipe.filestorage
... zopes = foobar
... parts =
... my-fs
... ''' % globals())
>>> print system(join('bin', 'buildout') + ' -q')
While:
...
Error: [collective.recipe.filestorage] The "filestorage" part expected but failed to find the following parts in ${buildout:parts}: foobar
如果Zope/ZEO部件正在自动识别,请确保我们不会意外地“唤醒”那些本来不会被包含在buildout中的部件。
>>> write('buildout.cfg',
... '''
... [buildout]
... extends = base.cfg
... parts =
... filestorage
... instance
...
... [instance]
... recipe = plone.recipe.zope2instance
... zope2-location = %(zope2_location)s
... user = me
...
... [filestorage]
... recipe = collective.recipe.filestorage
... parts =
... my-fs
...
... [foobar]
... recipe = plone.recipe.distros
... urls =
... ''' % globals())
>>> print system(join('bin', 'buildout') + ' -q')
>>> 'foobar' in os.listdir(os.path.join(sample_buildout, 'parts'))
False
请确保使用'extends'和+=或-=选项在buildout中正确找到实例部件。
>>> write('buildout.cfg',
... '''
... [buildout]
... extends = base.cfg
... parts =
... filestorage
... instance
...
... [instance]
... recipe = plone.recipe.zope2instance
... zope2-location = %(zope2_location)s
... user = me
...
... [filestorage]
... recipe = collective.recipe.filestorage
... parts =
... extendstest
... ''' % globals())
>>> write('prod.cfg',
... '''
... [buildout]
... extends = buildout.cfg
... parts +=
... foobar
...
... [foobar]
... recipe = plone.recipe.distros
... urls =
... ''' % globals())
>>> print system(join('bin', 'buildout') + ' -q -c prod.cfg')
>>> 'extendstest' in open(os.path.join(instance, 'etc', 'zope.conf')).read()
True
运行测试
collective.recipe.filestorage的subversion检出包含一个buildout,该buildout安装了一个运行测试的脚本。
只需运行
python2.4 bootstrap.py bin/buildout bin/test
已知问题:测试在单独的进程中运行buildout,因此目前无法在测试期间在配方中设置pdb断点进行调试。如果您需要这样做,请设置另一个使用collective.recipe.filestorage作为开发egg的buildout。
报告错误或提问
在Launchpad上有一个共享的错误跟踪器和帮助台:https://bugs.launchpad.net/collective.buildout/
变更历史
0.6 (2010-08-13)
支持ZEO服务器和客户端在不同的buildout中时使用配方。[ramon]
0.5 (2010-02-03)
除了plone.recipe.zope2zeoserver之外,还支持plone.recipe.zeoserver。[davisagli]
0.4 (2009-12-30)
添加了对创建与创建的文件存储部件关联的blob存储的支持。[davisagli]
修复了指示必须在文件存储部件之前安装哪些部件的消息。这修复了https://bugs.launchpad.net/bugs/433877(感谢,Jean Jordaan)[davisagli]
0.3 (2009-03-19)
避免安装所有部件,即使那些未在[buildout]部件变量中列出的部件。感谢Dylan Jay的诊断和修复。[davisagli]
修复了长描述(README.txt)的reStructuredText。[maurits]
0.2 (2008-04-30)
添加了zodb_container_class选项。[davisagli]
0.1 (2008-04-22)
地球日快乐![davisagli]
使用ZopeSkel创建配方。初始实现。[davisagli]
贡献者
David Glick [davisagli],作者
感谢
Dylan Jay
Ramon Navarro Bosch
项目详情
collective.recipe.filestorage-0.6.zip的散列
| 算法 | 散列摘要 | |
|---|---|---|
| SHA256 | 30bb817f8fd572f127044dd8e6bd8f352461ed108cd8c6e3230ff301a5275593 |
|
| MD5 | c0d85a82a858a860dc665dd38303fedd |
|
| BLAKE2b-256 | d1eb79f486e3ea2dc797e3b1efeaabd3c557a13ef8546f391f2a15152cfcb791 |