[Zope3-checkins] CVS: Zope3/src/zope/configuration - __init__.py:1.1.2.3 action.py:1.1.2.2 exceptions.py:1.1.2.2 hookregistry.py:1.1.2.3 meta.py:1.1.2.2 metaconfigure.py:1.1.2.2 metametaconfigure.py:1.1.2.2 metametaconfigurefordocgen.py:1.1.2.3 name.py:1.1.2.3 xmlconfig.py:1.1.2.3
Tim Peters
tim.one@comcast.net
Tue, 24 Dec 2002 21:21:33 -0500
Update of /cvs-repository/Zope3/src/zope/configuration
In directory cvs.zope.org:/tmp/cvs-serv19240/src/zope/configuration
Modified Files:
Tag: NameGeddon-branch
__init__.py action.py exceptions.py hookregistry.py meta.py
metaconfigure.py metametaconfigure.py
metametaconfigurefordocgen.py name.py xmlconfig.py
Log Message:
Whitespace normalization, via Python's Tools/scripts/reindent.py. The
files are fixed-points of that script now. Fixed a few cases where
code relied on significant trailing whitespace (ouch).
=== Zope3/src/zope/configuration/__init__.py 1.1.2.2 => 1.1.2.3 ===
--- Zope3/src/zope/configuration/__init__.py:1.1.2.2 Tue Dec 24 07:51:25 2002
+++ Zope3/src/zope/configuration/__init__.py Tue Dec 24 21:20:58 2002
@@ -2,14 +2,14 @@
#
# Copyright (c) 2001, 2002 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.
-#
+#
##############################################################################
"""Zope configuration support
=== Zope3/src/zope/configuration/action.py 1.1.2.1 => 1.1.2.2 ===
--- Zope3/src/zope/configuration/action.py:1.1.2.1 Mon Dec 23 14:32:42 2002
+++ Zope3/src/zope/configuration/action.py Tue Dec 24 21:20:58 2002
@@ -2,14 +2,14 @@
#
# Copyright (c) 2001, 2002 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.
-#
+#
##############################################################################
"""
@@ -18,4 +18,3 @@
def Action(discriminator, callable, args=(), kw={}):
return discriminator, callable, args, kw
-
=== Zope3/src/zope/configuration/exceptions.py 1.1.2.1 => 1.1.2.2 ===
--- Zope3/src/zope/configuration/exceptions.py:1.1.2.1 Mon Dec 23 14:32:42 2002
+++ Zope3/src/zope/configuration/exceptions.py Tue Dec 24 21:20:58 2002
@@ -2,14 +2,14 @@
#
# Copyright (c) 2002 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.
-#
+#
##############################################################################
"""Standard configuration errors
"""
@@ -17,4 +17,3 @@
class ConfigurationError(Exception):
"""There was an error in a configuration
"""
-
=== Zope3/src/zope/configuration/hookregistry.py 1.1.2.2 => 1.1.2.3 ===
--- Zope3/src/zope/configuration/hookregistry.py:1.1.2.2 Mon Dec 23 16:05:13 2002
+++ Zope3/src/zope/configuration/hookregistry.py Tue Dec 24 21:20:58 2002
@@ -2,14 +2,14 @@
#
# Copyright (c) 2001, 2002 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.
-#
+#
##############################################################################
"""
$Id$
@@ -21,20 +21,20 @@
class MissingHookableError(NotFoundError):
"""the stated hook has not been registered"""
-
+
class DuplicateHookError(DuplicationError):
"""an implementation for the given hook has already been registered"""
class BadHookableError(ZopeError):
"""hookable cannot be found or is not usable"""
-
+
class BadHookError(ZopeError):
"""hook cannot be set"""
-
+
class HookRegistry:
def __init__(self):
self._reg = {}
-
+
def addHookable(self, hname):
if hname in self._reg:
raise DuplicationError(hname)
@@ -42,20 +42,20 @@
defaultimpl = name.resolve(hname)
except ImportError:
raise BadHookableError("hookable %s cannot be found" % hname)
-
+
parent, last=self._getParentAndLast(hname)
implfunc="%s_hook" % last
-
+
if getattr(parent, implfunc, self) is self:
raise BadHookableError(
"""default hookable implementation (%s) cannot be found;
note it must be in the same module as the hookable""" %
implfunc)
-
+
self._reg[hname] = 0
-
+
def addHook(self, hookablename, hookname):
-
+
if not (hookablename in self._reg):
raise MissingHookableError(hookablename)
if self._reg[hookablename]:
@@ -71,30 +71,30 @@
'hookable cannot be found, but was found earlier: '
'some code has probably masked the hookable',
hookablename)
-
+
# This won't work as is: I'd have to create a NumberTypes and do
# various annoying checks
#if type(implementation) is not type (hookableDefault):
# raise BadHookError(
# 'hook and hookable must be same type')
-
+
# if they are functions, could check to see if signature is same
# (somewhat tricky because functions and methods could be
# interchangable but would have a different signature because
# of 'self')
-
+
# for now I'll leave both of the above to the sanity of the site
# configuration manager...
-
+
# find and import immediate parent
-
+
parent,last = self._getParentAndLast(hookablename)
-
+
# set parent.last to implementation
setattr(parent, "%s_hook" % last, implementation)
-
+
self._reg[hookablename] = hookname
-
+
def _getParentAndLast(self, hookablename):
if hookablename.endswith('.') or hookablename.endswith('+'):
hookablename = hookablename[:-1]
@@ -122,22 +122,22 @@
break
parent = child
child = grand
-
+
if type(parent) is not ModuleType:
raise BadHookableError("parent of hookable must be a module")
-
+
return parent, last
-
+
def getHooked(self):
return [(key, self._reg[key])
for key in self._reg
if self._reg[key]]
-
+
def getUnhooked(self):
return [(key, self._reg[key])
for key in self._reg
if not self._reg[key]]
-
+
def getHookables(self):
return [(key, self._reg[key])
for key in self._reg]
=== Zope3/src/zope/configuration/meta.py 1.1.2.1 => 1.1.2.2 ===
--- Zope3/src/zope/configuration/meta.py:1.1.2.1 Mon Dec 23 14:32:42 2002
+++ Zope3/src/zope/configuration/meta.py Tue Dec 24 21:20:58 2002
@@ -2,14 +2,14 @@
#
# Copyright (c) 2001, 2002 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.
-#
+#
##############################################################################
"""Registration of registration directives
@@ -89,7 +89,7 @@
subdirective registry will be returned.
"""
-
+
subdirs = _directives.get(name,(None,{}))[1]
_directives[name] = callable, subdirs
return subdirs
@@ -195,7 +195,7 @@
- A registry for looking up subdirectives.
"""
-
+
if _custom_directives and (_name in _custom_directives):
callable, subs = _custom_directives[_name]
else:
@@ -237,7 +237,7 @@
subsubs, handler_method = subdirs[_name]
except KeyError:
raise InvalidDirective(_name)
-
+
callable = getattr(base, handler_method)
return _exe(callable, subsubs, _context, kw)
@@ -287,7 +287,7 @@
namespace = namespace or self._namespace
subs = register((namespace, name), _context.resolve(handler))
return subs, namespace
-
+
def directive(self, *args, **kw):
subs, namespace = self._register(*args, **kw)
return Subdirective(subs, namespace=namespace)
@@ -299,11 +299,11 @@
class Subdirective:
"""This is the meta-meta-directive"""
- #
+ #
# Unlike other directives, it doesn't return any actions, but
# takes action right away, since its actions are needed to process other
# directives.
- #
+ #
# For this reason, this isn't a good directive example.
__implements__ = ISubdirectiveHandler
=== Zope3/src/zope/configuration/metaconfigure.py 1.1.2.1 => 1.1.2.2 ===
--- Zope3/src/zope/configuration/metaconfigure.py:1.1.2.1 Mon Dec 23 14:32:42 2002
+++ Zope3/src/zope/configuration/metaconfigure.py Tue Dec 24 21:20:58 2002
@@ -2,14 +2,14 @@
#
# Copyright (c) 2001, 2002 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.
-#
+#
##############################################################################
"""
$Id$
@@ -50,6 +50,3 @@
args=(name, implementation)
)
]
-
-
-
=== Zope3/src/zope/configuration/metametaconfigure.py 1.1.2.1 => 1.1.2.2 ===
--- Zope3/src/zope/configuration/metametaconfigure.py:1.1.2.1 Mon Dec 23 14:32:42 2002
+++ Zope3/src/zope/configuration/metametaconfigure.py Tue Dec 24 21:20:58 2002
@@ -2,14 +2,14 @@
#
# Copyright (c) 2001, 2002 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.
-#
+#
##############################################################################
"""
$Id$
=== Zope3/src/zope/configuration/metametaconfigurefordocgen.py 1.1.2.2 => 1.1.2.3 ===
--- Zope3/src/zope/configuration/metametaconfigurefordocgen.py:1.1.2.2 Tue Dec 24 07:51:25 2002
+++ Zope3/src/zope/configuration/metametaconfigurefordocgen.py Tue Dec 24 21:20:58 2002
@@ -2,14 +2,14 @@
#
# Copyright (c) 2001, 2002 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.
-#
+#
##############################################################################
"""
$Id$
@@ -61,11 +61,11 @@
_metadataKey = "__zope.configuration.metadataKey__"
def _recordCommandMetadata(subs, description, handler=None):
- if _metadataKey not in subs: subs[_metadataKey] = {}
- md = subs[_metadataKey]
- if 'attributes' not in md: md['attributes'] = {}
- if description: md['description'] = ' '.join(description.split())
- if handler: md['handler'] = handler
+ if _metadataKey not in subs: subs[_metadataKey] = {}
+ md = subs[_metadataKey]
+ if 'attributes' not in md: md['attributes'] = {}
+ if description: md['description'] = ' '.join(description.split())
+ if handler: md['handler'] = handler
class DirectiveNamespace(baseDirectiveNamespace):
=== Zope3/src/zope/configuration/name.py 1.1.2.2 => 1.1.2.3 ===
--- Zope3/src/zope/configuration/name.py:1.1.2.2 Mon Dec 23 16:05:13 2002
+++ Zope3/src/zope/configuration/name.py Tue Dec 24 21:20:58 2002
@@ -2,14 +2,14 @@
#
# Copyright (c) 2001, 2002 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.
-#
+#
##############################################################################
"""Provide configuration object name resolution
@@ -22,7 +22,7 @@
def resolve(name, package='zopeproducts', _silly=('__doc__',), _globals={}):
name = name.strip()
-
+
if name.startswith('.'):
name=package+name
@@ -38,7 +38,7 @@
if not mod:
return __import__(name, _globals, _globals, _silly)
-
+
while 1:
m=__import__(mod, _globals, _globals, _silly)
try:
@@ -46,7 +46,7 @@
except AttributeError:
if not repeat:
return __import__(name, _globals, _globals, _silly)
-
+
else:
if not repeat or (not isinstance(a, ModuleType)):
return a
@@ -79,7 +79,7 @@
# The package didn't matter
return file
raise
-
+
path = os.path.split(package.__file__)[0]
if file:
path = os.path.join(path, file)
=== Zope3/src/zope/configuration/xmlconfig.py 1.1.2.2 => 1.1.2.3 ===
--- Zope3/src/zope/configuration/xmlconfig.py:1.1.2.2 Mon Dec 23 16:05:13 2002
+++ Zope3/src/zope/configuration/xmlconfig.py Tue Dec 24 21:20:58 2002
@@ -2,14 +2,14 @@
#
# Copyright (c) 2001, 2002 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.
-#
+#
##############################################################################
"""
@@ -29,7 +29,7 @@
from zope.configuration.exceptions import ConfigurationError
# marker used in Context class and XMLConfig class to indicate
-# that a particular zcml file was given no "package" attribute
+# that a particular zcml file was given no "package" attribute
# when included, and the same went for all of its parents.
_NO_MODULE_GIVEN = object()
@@ -45,7 +45,7 @@
mess = str(mess)
else:
mess = "\n%s: %s" % (etype.__name__, mess)
-
+
self.lno = locator.getLineNumber()
self.cno = locator.getColumnNumber()
self.sid = locator.getSystemId()
@@ -74,7 +74,7 @@
class ConfigurationHandler(ContentHandler):
- __top_name = 'http://namespaces.zope.org/zope', 'zopeConfigure'
+ __top_name = 'http://namespaces.zope.org/zope', 'zopeConfigure'
def __init__(self, actions, context, directives=None, testing=0):
self.__stack = []
@@ -96,7 +96,7 @@
for (ns, aname), value in attrs.items():
if ns is None:
self.__context.file_attr(aname, value)
-
+
stack.append(None)
return
@@ -117,8 +117,8 @@
if self.__testing:
raise
raise ZopeXMLConfigurationError, (
- self.__locator, v), sys.exc_info()[2]
-
+ self.__locator, v), sys.exc_info()[2]
+
else:
subs = self.__stack[-1]
if subs is None:
@@ -130,7 +130,7 @@
if self.__testing:
raise
raise ZopeXMLConfigurationError, (
- self.__locator, v), sys.exc_info()[2]
+ self.__locator, v), sys.exc_info()[2]
def endElementNS(self, name, qname):
subs = self.__stack.pop()
@@ -144,7 +144,7 @@
if self.__testing:
raise
raise ZopeXMLConfigurationError, (
- self.__locator, str(v)), sys.exc_info()[2]
+ self.__locator, str(v)), sys.exc_info()[2]
append = self.__actions.append
@@ -173,10 +173,10 @@
File "%s", line %s column %s
File "%s", line %s column %s
""" % (self.des,
- self.l1[2], self.l1[0], self.l1[1],
+ self.l1[2], self.l1[0], self.l1[1],
self.l2[2], self.l2[0], self.l2[1],
)
-
+
class Context:
def __init__(self, stack, module):
self.__stackcopy = tuple(stack)
@@ -192,7 +192,7 @@
def resolve(self, dottedname):
return name.resolve(dottedname, self.__package)
-
+
def getNormalizedName(self, dottedname):
return name.getNormalizedName(dottedname, self.__package)
@@ -207,10 +207,10 @@
def packageWasSet(self):
return self.__package is not None
-
+
def package(self):
return self.__package
-
+
def xmlconfig(file, actions=None, context=None, directives=None,
testing=0):
if context is None:
@@ -220,7 +220,7 @@
call = actions = []
else:
call = 0
-
+
src = InputSource(getattr(file, 'name', '<string>'))
src.setByteStream(file)
parser = make_parser()
@@ -239,7 +239,7 @@
raise ZopeConflictingConfigurationError(
descriptors[des], loc, des)
descriptors[des] = loc
-
+
callable(*args, **kw)
def testxmlconfig(file, actions=None, context=None, directives=None):
@@ -248,7 +248,7 @@
This is useful for testing, as it doesn't mask exception types.
"""
return xmlconfig(file, actions, context, directives, testing=1)
-
+
class ZopeConfigurationConflictError(ZopeXMLConfigurationError):
def __init__(self, conflicts):
@@ -261,9 +261,9 @@
for loc in locs:
r.append(' File "%s", line %s column %s' %
(loc[2], loc[0], loc[1]))
-
+
return "\n".join(r)
-
+
class XMLConfig:
@@ -272,7 +272,7 @@
module_dir = abspath(os.path.split(module.__file__)[0])
file_name = os.path.join(module_dir, file_name)
-
+
self._actions = []
self._directives = {('http://namespaces.zope.org/zope', 'include'):
(self.include, {})}