[Checkins] SVN: zc.recipe.filestorage/trunk/ initial version
Jim Fulton
jim at zope.com
Wed Jun 28 18:06:36 EDT 2006
Log message for revision 68891:
initial version
Changed:
A zc.recipe.filestorage/trunk/README.txt
A zc.recipe.filestorage/trunk/setup.cfg
A zc.recipe.filestorage/trunk/setup.py
A zc.recipe.filestorage/trunk/zc/
A zc.recipe.filestorage/trunk/zc/__init__.py
A zc.recipe.filestorage/trunk/zc/recipe/
A zc.recipe.filestorage/trunk/zc/recipe/__init__.py
A zc.recipe.filestorage/trunk/zc/recipe/filestorage/
A zc.recipe.filestorage/trunk/zc/recipe/filestorage/__init__.py
A zc.recipe.filestorage/trunk/zc/recipe/filestorage/tests.py
-=-
Added: zc.recipe.filestorage/trunk/README.txt
===================================================================
--- zc.recipe.filestorage/trunk/README.txt 2006-06-28 20:57:30 UTC (rev 68890)
+++ zc.recipe.filestorage/trunk/README.txt 2006-06-28 22:06:36 UTC (rev 68891)
@@ -0,0 +1,75 @@
+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']
+
+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.
Property changes on: zc.recipe.filestorage/trunk/README.txt
___________________________________________________________________
Name: svn:eol-style
+ native
Added: zc.recipe.filestorage/trunk/setup.cfg
===================================================================
--- zc.recipe.filestorage/trunk/setup.cfg 2006-06-28 20:57:30 UTC (rev 68890)
+++ zc.recipe.filestorage/trunk/setup.cfg 2006-06-28 22:06:36 UTC (rev 68891)
@@ -0,0 +1,3 @@
+[egg_info]
+tag_build = .dev
+tag_svn_revision = 1
Property changes on: zc.recipe.filestorage/trunk/setup.cfg
___________________________________________________________________
Name: svn:eol-style
+ native
Added: zc.recipe.filestorage/trunk/setup.py
===================================================================
--- zc.recipe.filestorage/trunk/setup.py 2006-06-28 20:57:30 UTC (rev 68890)
+++ zc.recipe.filestorage/trunk/setup.py 2006-06-28 22:06:36 UTC (rev 68891)
@@ -0,0 +1,23 @@
+from setuptools import setup, find_packages
+
+name = "zc.recipe.filestorage"
+setup(
+ name = name,
+ version = "1.0.dev",
+ author = "Jim Fulton",
+ author_email = "jim at zope.com",
+ description = "ZC Buildout recipe for defining a file-storage",
+ license = "ZPL 2.1",
+ keywords = "zope3",
+ url='http://svn.zope.org/'+name,
+ download_url='http://download.zope.org/distribution',
+
+ packages = find_packages(),
+ include_package_data = True,
+ data_files = [('.', ['README.txt'])],
+ namespace_packages = ['zc', 'zc.recipe'],
+ install_requires = ['zc.buildout', 'zope.testing', 'setuptools'],
+ dependency_links = ['http://download.zope.org/distribution/'],
+ entry_points = {'zc.buildout':
+ ['default = %s:Recipe' % name]},
+ )
Property changes on: zc.recipe.filestorage/trunk/setup.py
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added: zc.recipe.filestorage/trunk/zc/__init__.py
===================================================================
--- zc.recipe.filestorage/trunk/zc/__init__.py 2006-06-28 20:57:30 UTC (rev 68890)
+++ zc.recipe.filestorage/trunk/zc/__init__.py 2006-06-28 22:06:36 UTC (rev 68891)
@@ -0,0 +1,6 @@
+# namespace package boilerplate
+try:
+ __import__('pkg_resources').declare_namespace(__name__)
+except ImportError, e:
+ from pkgutil import extend_path
+ __path__ = extend_path(__path__, __name__)
Property changes on: zc.recipe.filestorage/trunk/zc/__init__.py
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added: zc.recipe.filestorage/trunk/zc/recipe/__init__.py
===================================================================
--- zc.recipe.filestorage/trunk/zc/recipe/__init__.py 2006-06-28 20:57:30 UTC (rev 68890)
+++ zc.recipe.filestorage/trunk/zc/recipe/__init__.py 2006-06-28 22:06:36 UTC (rev 68891)
@@ -0,0 +1,6 @@
+# namespace package boilerplate
+try:
+ __import__('pkg_resources').declare_namespace(__name__)
+except ImportError, e:
+ from pkgutil import extend_path
+ __path__ = extend_path(__path__, __name__)
Property changes on: zc.recipe.filestorage/trunk/zc/recipe/__init__.py
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added: zc.recipe.filestorage/trunk/zc/recipe/filestorage/__init__.py
===================================================================
--- zc.recipe.filestorage/trunk/zc/recipe/filestorage/__init__.py 2006-06-28 20:57:30 UTC (rev 68890)
+++ zc.recipe.filestorage/trunk/zc/recipe/filestorage/__init__.py 2006-06-28 22:06:36 UTC (rev 68891)
@@ -0,0 +1,34 @@
+import logging, os
+
+class Recipe:
+
+ def __init__(self, buildout, name, options):
+ self.name, self.options = name, options
+ path = options.get('path')
+ if path is None:
+ path = os.path.join(buildout['buildout']['parts-directory'],
+ self.name, 'Data.fs')
+ self.make_part = True
+ else:
+ path = os.path.join(buildout['buildout']['directory'], path)
+ if not os.path.exists(path):
+ logging.getLogger('zc.recipe.filestorage').error(
+ "%s does not exixt", path)
+ self.make_part = False
+
+ options['path'] = path
+ options['zconfig'] = template % path
+
+ def install(self):
+ if self.make_part:
+ part = os.path.dirname(self.options['path'])
+ if not os.path.exists(part):
+ os.mkdir(part)
+
+template = """\
+<zodb>
+ <filestorage>
+ path %s
+ </filestorage>
+</zodb>
+"""
Property changes on: zc.recipe.filestorage/trunk/zc/recipe/filestorage/__init__.py
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added: zc.recipe.filestorage/trunk/zc/recipe/filestorage/tests.py
===================================================================
--- zc.recipe.filestorage/trunk/zc/recipe/filestorage/tests.py 2006-06-28 20:57:30 UTC (rev 68890)
+++ zc.recipe.filestorage/trunk/zc/recipe/filestorage/tests.py 2006-06-28 22:06:36 UTC (rev 68891)
@@ -0,0 +1,30 @@
+##############################################################################
+#
+# Copyright (c) 2006 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+import os, re, unittest
+import pkg_resources
+from zope.testing import doctest, renormalizing
+
+def test_suite():
+ global __test__
+ req = pkg_resources.Requirement.parse('zc.recipe.filestorage')
+ __test__ = dict(README=pkg_resources.resource_string(req, 'README.txt'))
+ return doctest.DocTestSuite(
+ checker=renormalizing.RENormalizing([
+ (re.compile('\S+%(sep)s\w+%(sep)s\w+.fs'
+ % dict(sep=os.path.sep)),
+ r'/tmp/data/Data.fs'),
+ (re.compile('\S+sample-(\w+)'), r'/sample-\1'),
+ ]),
+ )
+
Property changes on: zc.recipe.filestorage/trunk/zc/recipe/filestorage/tests.py
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
More information about the Checkins
mailing list