[Checkins] SVN: zc.configuration/branches/dev/ initial

Jim Fulton jim at zope.com
Sat Sep 29 14:56:59 EDT 2007


Log message for revision 80406:
  initial

Changed:
  _U  zc.configuration/branches/dev/
  A   zc.configuration/branches/dev/CHANGES.txt
  A   zc.configuration/branches/dev/README.txt
  A   zc.configuration/branches/dev/buildout.cfg
  A   zc.configuration/branches/dev/setup.py
  A   zc.configuration/branches/dev/src/
  A   zc.configuration/branches/dev/src/zc/
  A   zc.configuration/branches/dev/src/zc/__init__.py
  A   zc.configuration/branches/dev/src/zc/configuration/
  A   zc.configuration/branches/dev/src/zc/configuration/README.txt
  A   zc.configuration/branches/dev/src/zc/configuration/__init__.py
  A   zc.configuration/branches/dev/src/zc/configuration/demo/
  A   zc.configuration/branches/dev/src/zc/configuration/demo/__init__.py
  A   zc.configuration/branches/dev/src/zc/configuration/demo/configure.zcml
  A   zc.configuration/branches/dev/src/zc/configuration/demo/spam.zcml
  A   zc.configuration/branches/dev/src/zc/configuration/demo/sub/
  A   zc.configuration/branches/dev/src/zc/configuration/demo/sub/__init__.py
  A   zc.configuration/branches/dev/src/zc/configuration/demo/sub/configure.zcml
  A   zc.configuration/branches/dev/src/zc/configuration/meta.zcml
  A   zc.configuration/branches/dev/src/zc/configuration/tests.py
  A   zc.configuration/branches/dev/src/zc/configuration/zcml.py

-=-

Property changes on: zc.configuration/branches/dev
___________________________________________________________________
Name: svn:ignore
   + develop-eggs
bin
parts
doc.txt
dist


Added: zc.configuration/branches/dev/CHANGES.txt
===================================================================
--- zc.configuration/branches/dev/CHANGES.txt	                        (rev 0)
+++ zc.configuration/branches/dev/CHANGES.txt	2007-09-29 18:56:58 UTC (rev 80406)
@@ -0,0 +1,5 @@
+
+1.0
+===
+
+Initial release.


Property changes on: zc.configuration/branches/dev/CHANGES.txt
___________________________________________________________________
Name: svn:eol-style
   + native

Added: zc.configuration/branches/dev/README.txt
===================================================================
--- zc.configuration/branches/dev/README.txt	                        (rev 0)
+++ zc.configuration/branches/dev/README.txt	2007-09-29 18:56:58 UTC (rev 80406)
@@ -0,0 +1,5 @@
+******************************************************************
+zope.configuration extensions to filter out unwanted configuration
+******************************************************************
+
+.. contents::


Property changes on: zc.configuration/branches/dev/README.txt
___________________________________________________________________
Name: svn:eol-style
   + native

Added: zc.configuration/branches/dev/buildout.cfg
===================================================================
--- zc.configuration/branches/dev/buildout.cfg	                        (rev 0)
+++ zc.configuration/branches/dev/buildout.cfg	2007-09-29 18:56:58 UTC (rev 80406)
@@ -0,0 +1,7 @@
+[buildout]
+develop = .
+parts = test
+
+[test]
+recipe = zc.recipe.testrunner
+eggs = zc.configuration


Property changes on: zc.configuration/branches/dev/buildout.cfg
___________________________________________________________________
Name: svn:eol-style
   + native

Added: zc.configuration/branches/dev/setup.py
===================================================================
--- zc.configuration/branches/dev/setup.py	                        (rev 0)
+++ zc.configuration/branches/dev/setup.py	2007-09-29 18:56:58 UTC (rev 80406)
@@ -0,0 +1,39 @@
+import os
+from setuptools import setup, find_packages
+
+def read(*rnames):
+    return open(os.path.join(os.path.dirname(__file__), *rnames)).read()
+
+long_description = (
+        read('README.txt')
+        + '\n' +
+        read('CHANGES.txt')
+        + '\n' +
+        'Detailed Documentation\n'
+        '**********************\n'
+        + '\n' +
+        read('src', 'zc', 'configuration', 'README.txt')
+        + '\n' +
+        'Download\n'
+        '**********************\n'
+        )
+
+open('doc.txt', 'w').write(long_description)
+
+setup(
+    name = "zc.configuration",
+    description = "Extensions to zope.configuration",
+    long_description = long_description,
+    version = "1.0",
+    license = "ZPL 1.1",
+    packages = find_packages('src'),
+    include_package_data = True,
+    zip_safe = False,
+    package_dir = {'':'src'},
+    namespace_packages = ['zc'],
+    install_requires = [
+        'setuptools',
+        'zope.testing',
+        'zope.configuration',
+        ],
+    )


Property changes on: zc.configuration/branches/dev/setup.py
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native

Added: zc.configuration/branches/dev/src/zc/__init__.py
===================================================================
--- zc.configuration/branches/dev/src/zc/__init__.py	                        (rev 0)
+++ zc.configuration/branches/dev/src/zc/__init__.py	2007-09-29 18:56:58 UTC (rev 80406)
@@ -0,0 +1,2 @@
+# namespace package boilerplate
+__import__('pkg_resources').declare_namespace(__name__)


Property changes on: zc.configuration/branches/dev/src/zc/__init__.py
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native

Added: zc.configuration/branches/dev/src/zc/configuration/README.txt
===================================================================
--- zc.configuration/branches/dev/src/zc/configuration/README.txt	                        (rev 0)
+++ zc.configuration/branches/dev/src/zc/configuration/README.txt	2007-09-29 18:56:58 UTC (rev 80406)
@@ -0,0 +1,59 @@
+Configuration Extensions for Filtering or Inhibiting Configuration
+==================================================================
+
+The zc.configuration package provides some configuration directives
+for inhibiting configuration.  The first of these is the excluse
+directive.  It is used to exclude processing of configuration
+files. It is usedful when including a configuration that includes some
+other configuration that you don't want.  It must be used before
+including the files to be excluded.
+
+First, let's look at an example.  The zope.configuration.demo package
+has a ZCML configuration that includes some other configuration files.
+
+We'll set a log handler so we can see what's going on:
+
+    >>> import logging, sys
+    >>> logger = logging.getLogger('config')
+    >>> oldlevel = logger.level
+    >>> logger.setLevel(logging.DEBUG)
+    >>> handler = logging.StreamHandler(sys.stdout)
+    >>> logger.addHandler(handler)
+ 
+Now, we'll include the zc.configuration.demo config:
+
+    >>> from zope.configuration import xmlconfig
+    >>> _ = xmlconfig.string('<include package="zc.configuration.demo" />')
+    include /zc.configuration/src/zc/configuration/demo/configure.zcml
+    include /zc.configuration/src/zc/configuration/demo/sub/configure.zcml
+    include /zc.configuration/src/zc/configuration/demo/spam.zcml
+
+Each run of the configuration machinery runs with fresh state, so
+rerunning gives the same thing:
+
+    >>> _ = xmlconfig.string('<include package="zc.configuration.demo" />')
+    include /zc.configuration/src/zc/configuration/demo/configure.zcml
+    include /zc.configuration/src/zc/configuration/demo/sub/configure.zcml
+    include /zc.configuration/src/zc/configuration/demo/spam.zcml
+
+Now, we'll load the zc.configuration meta.zcml and use the exclude
+directive to include the two files included by the configuration file
+in zc.configuration.demo:
+
+    >>> _ = xmlconfig.string(
+    ... '''
+    ... <configure  xmlns="http://namespaces.zope.org/zope">
+    ...   <include package="zc.configuration" file="meta.zcml" />
+    ...   <exclude package="zc.configuration.demo.sub" />
+    ...   <exclude package="zc.configuration.demo" file="spam.zcml" />
+    ...   <include package="zc.configuration.demo" />
+    ... </configure>
+    ... ''')
+    include /zc.configuration/src/zc/configuration/meta.zcml
+    include /zc.configuration/src/zc/configuration/demo/configure.zcml
+    
+
+.. cleanup
+
+    >>> logger.setLevel(oldlevel)
+    >>> logger.removeHandler(handler)


Property changes on: zc.configuration/branches/dev/src/zc/configuration/README.txt
___________________________________________________________________
Name: svn:eol-style
   + native

Added: zc.configuration/branches/dev/src/zc/configuration/__init__.py
===================================================================
--- zc.configuration/branches/dev/src/zc/configuration/__init__.py	                        (rev 0)
+++ zc.configuration/branches/dev/src/zc/configuration/__init__.py	2007-09-29 18:56:58 UTC (rev 80406)
@@ -0,0 +1 @@
+#


Property changes on: zc.configuration/branches/dev/src/zc/configuration/__init__.py
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native

Added: zc.configuration/branches/dev/src/zc/configuration/demo/__init__.py
===================================================================
--- zc.configuration/branches/dev/src/zc/configuration/demo/__init__.py	                        (rev 0)
+++ zc.configuration/branches/dev/src/zc/configuration/demo/__init__.py	2007-09-29 18:56:58 UTC (rev 80406)
@@ -0,0 +1 @@
+#


Property changes on: zc.configuration/branches/dev/src/zc/configuration/demo/__init__.py
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native

Added: zc.configuration/branches/dev/src/zc/configuration/demo/configure.zcml
===================================================================
--- zc.configuration/branches/dev/src/zc/configuration/demo/configure.zcml	                        (rev 0)
+++ zc.configuration/branches/dev/src/zc/configuration/demo/configure.zcml	2007-09-29 18:56:58 UTC (rev 80406)
@@ -0,0 +1,6 @@
+<configure>
+
+<include package=".sub" />
+<include file="spam.zcml" />
+
+</configure>


Property changes on: zc.configuration/branches/dev/src/zc/configuration/demo/configure.zcml
___________________________________________________________________
Name: svn:eol-style
   + native

Added: zc.configuration/branches/dev/src/zc/configuration/demo/spam.zcml
===================================================================
--- zc.configuration/branches/dev/src/zc/configuration/demo/spam.zcml	                        (rev 0)
+++ zc.configuration/branches/dev/src/zc/configuration/demo/spam.zcml	2007-09-29 18:56:58 UTC (rev 80406)
@@ -0,0 +1 @@
+<configure />


Property changes on: zc.configuration/branches/dev/src/zc/configuration/demo/spam.zcml
___________________________________________________________________
Name: svn:eol-style
   + native

Added: zc.configuration/branches/dev/src/zc/configuration/demo/sub/__init__.py
===================================================================
--- zc.configuration/branches/dev/src/zc/configuration/demo/sub/__init__.py	                        (rev 0)
+++ zc.configuration/branches/dev/src/zc/configuration/demo/sub/__init__.py	2007-09-29 18:56:58 UTC (rev 80406)
@@ -0,0 +1 @@
+#


Property changes on: zc.configuration/branches/dev/src/zc/configuration/demo/sub/__init__.py
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native

Added: zc.configuration/branches/dev/src/zc/configuration/demo/sub/configure.zcml
===================================================================
--- zc.configuration/branches/dev/src/zc/configuration/demo/sub/configure.zcml	                        (rev 0)
+++ zc.configuration/branches/dev/src/zc/configuration/demo/sub/configure.zcml	2007-09-29 18:56:58 UTC (rev 80406)
@@ -0,0 +1 @@
+<configure />


Property changes on: zc.configuration/branches/dev/src/zc/configuration/demo/sub/configure.zcml
___________________________________________________________________
Name: svn:eol-style
   + native

Added: zc.configuration/branches/dev/src/zc/configuration/meta.zcml
===================================================================
--- zc.configuration/branches/dev/src/zc/configuration/meta.zcml	                        (rev 0)
+++ zc.configuration/branches/dev/src/zc/configuration/meta.zcml	2007-09-29 18:56:58 UTC (rev 80406)
@@ -0,0 +1,10 @@
+<configure xmlns="http://namespaces.zope.org/meta">
+
+  <directive
+     namespace="http://namespaces.zope.org/zope"
+     name="exclude"
+     schema="zope.configuration.xmlconfig.IInclude"
+     handler=".zcml.exclude"
+     />
+
+</configure>


Property changes on: zc.configuration/branches/dev/src/zc/configuration/meta.zcml
___________________________________________________________________
Name: svn:eol-style
   + native

Added: zc.configuration/branches/dev/src/zc/configuration/tests.py
===================================================================
--- zc.configuration/branches/dev/src/zc/configuration/tests.py	                        (rev 0)
+++ zc.configuration/branches/dev/src/zc/configuration/tests.py	2007-09-29 18:56:58 UTC (rev 80406)
@@ -0,0 +1,34 @@
+##############################################################################
+#
+# 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
+from zope.testing import doctest, setupstack, renormalizing
+
+def setUp(test):
+    setupstack.setUpDirectory(test)
+
+def test_suite():
+    return unittest.TestSuite((
+        doctest.DocFileSuite(
+            'README.txt', setUp=setUp, tearDown=setupstack.tearDown,
+            checker=renormalizing.RENormalizing([
+                (re.compile('include [^\n]+zc.configuration[\S+]'),
+                 'include /zc.configuration\2'),
+                (re.compile(r'\\'), '/'),
+                ])
+            ),
+        ))
+
+if __name__ == '__main__':
+    unittest.main(defaultTest='test_suite')
+


Property changes on: zc.configuration/branches/dev/src/zc/configuration/tests.py
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native

Added: zc.configuration/branches/dev/src/zc/configuration/zcml.py
===================================================================
--- zc.configuration/branches/dev/src/zc/configuration/zcml.py	                        (rev 0)
+++ zc.configuration/branches/dev/src/zc/configuration/zcml.py	2007-09-29 18:56:58 UTC (rev 80406)
@@ -0,0 +1,45 @@
+##############################################################################
+#
+# Copyright (c) 2006 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (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 glob
+
+import zope.interface
+import zope.configuration.config
+import zope.schema
+    
+def exclude(_context, file=None, package=None, files=None):
+    """Exclude a zcml file
+    """
+
+    if files:
+        if file:
+            raise ValueError("Must specify only one of file or files")
+    elif not file:
+        file = 'configure.zcml'
+
+
+    context = zope.configuration.config.GroupingContextDecorator(_context)
+    if package is not None:
+        context.package = package
+        context.basepath = None
+
+    if files:
+        paths = glob.glob(context.path(files))
+        paths = zip([path.lower() for path in paths], paths)
+        paths.sort()
+        paths = [path for (l, path) in paths]
+    else:
+        paths = [context.path(file)]
+
+    for path in paths:
+        context.processFile(path)


Property changes on: zc.configuration/branches/dev/src/zc/configuration/zcml.py
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native



More information about the Checkins mailing list