[Zope-Checkins] CVS: Zope3/lib/python/Zope/Configuration/tests - Directives.py:1.1.2.4.4.1 testMeta.py:1.1.2.7.4.1
Barry Warsaw
barry@wooz.org
Thu, 21 Mar 2002 19:27:28 -0500
Update of /cvs-repository/Zope3/lib/python/Zope/Configuration/tests
In directory cvs.zope.org:/tmp/cvs-serv22971/lib/python/Zope/Configuration/tests
Modified Files:
Tag: contextual-directives
Directives.py testMeta.py
Log Message:
This is work to pass context to zcml directives, so that directives
know where they live. This is inspired by some suggested changes to
the naming syntax that Stephan and I discussed with Jim.
Specifically, a leading dot, as in
.JobBoardEx.JobList.
would signify a name relative to the current package, instead of
relative to ZopeProducts. Also, we'd like to change the trailing dot
to a `+' for signifying "look-the-last-name-up-recursively-until-you-
can't-anymore". E.g.:
.JobBoardEx.JobList+
I'm committing this on a branch because it breaks the unit tests and
I'm not sure of the best way to fix the remaining 10 failures. Jim
suggests that we commit these to the branch so that he can work on
them too.
=== Zope3/lib/python/Zope/Configuration/tests/Directives.py 1.1.2.4 => 1.1.2.4.4.1 ===
__implements__ = INonEmptyDirective
- def __init__(self, name, permission=None, methods=None):
+ def __init__(self, _context, name, permission=None, methods=None):
self._name=name
self._permission=permission
self._methods=methods
self._children=[]
+ self.__context = _context
def __call__(self):
if not self._children:
@@ -39,7 +40,7 @@
else:
return ()
- def protect(self, permission=None, methods=None):
+ def protect(self, _context, permission=None, methods=None):
if permission is None: permission=self._permission
if permission is None: raise 'no perm'
p=self._name, permission, methods
@@ -49,7 +50,7 @@
done = []
-def doit(name):
+def doit(_context, name):
return [('d', done.append, (name,))]
def clearDirectives():
=== Zope3/lib/python/Zope/Configuration/tests/testMeta.py 1.1.2.7 => 1.1.2.7.4.1 ===
import protectClass, protections, doit, done
from Zope.Testing.CleanUp import CleanUp # Base class w registry cleanup
+from Zope.Configuration import name
ns='http://www.zope.org/NS/Zope3/test'
@@ -21,11 +22,11 @@
from Zope.Configuration.meta \
import register, registersub, begin, end, InvalidDirective
- self.assertRaises(InvalidDirective, begin, None, (ns, 'doit'))
+ self.assertRaises(InvalidDirective, begin, None, name, (ns, 'doit'))
register((ns, 'doit'), doit)
- subs = begin(None, (ns, 'doit'), name='splat')
+ subs = begin(None, name, (ns, 'doit'), name='splat')
(des, callable, args, kw), = end(subs)
self.assertEqual(des, 'd')
callable(*args)
@@ -39,7 +40,7 @@
subs = register((ns, 'protectClass'), protectClass)
registersub(subs, (ns, 'protect'))
- subs=begin(None, (ns, 'protectClass'),
+ subs=begin(None, name, (ns, 'protectClass'),
name=".Contact", permission="splat", methods='update')
(des, callable, args, kw), = end(subs)
@@ -55,7 +56,7 @@
subs = register((ns, 'protectClass'), protectClass)
registersub(subs, (ns, 'protect'))
- subs = begin(None, (ns, 'protectClass'), name=".Contact")
+ subs = begin(None, name, (ns, 'protectClass'), name=".Contact")
actions = end(sub(subs, (ns, 'protect'),
permission='edit', methods='update'))