[Checkins] SVN: zope.configuration/trunk/ - Allow "info" and "includepath" to be passed optionally to context.action.
Chris McDonough
chrism at plope.com
Fri Dec 10 13:38:40 EST 2010
Log message for revision 118794:
- Allow "info" and "includepath" to be passed optionally to context.action.
Changed:
U zope.configuration/trunk/CHANGES.txt
U zope.configuration/trunk/src/zope/configuration/config.py
U zope.configuration/trunk/src/zope/configuration/interfaces.py
-=-
Modified: zope.configuration/trunk/CHANGES.txt
===================================================================
--- zope.configuration/trunk/CHANGES.txt 2010-12-10 18:19:30 UTC (rev 118793)
+++ zope.configuration/trunk/CHANGES.txt 2010-12-10 18:38:39 UTC (rev 118794)
@@ -5,6 +5,7 @@
3.7.3 (unreleased)
------------------
+- Allow "info" and "includepath" to be passed optionally to context.action.
3.7.2 (2010-04-30)
------------------
Modified: zope.configuration/trunk/src/zope/configuration/config.py
===================================================================
--- zope.configuration/trunk/src/zope/configuration/config.py 2010-12-10 18:19:30 UTC (rev 118793)
+++ zope.configuration/trunk/src/zope/configuration/config.py 2010-12-10 18:38:39 UTC (rev 118794)
@@ -314,7 +314,8 @@
self._seen_files.add(path)
return True
- def action(self, discriminator, callable=None, args=(), kw={}, order=0):
+ def action(self, discriminator, callable=None, args=(), kw={}, order=0,
+ includepath=None, info=None):
"""Add an action with the given discriminator, callable and arguments
For testing purposes, the callable and arguments may be omitted.
@@ -352,20 +353,38 @@
>>> c.actions[-1]
(None, None, (), {}, ('foo.zcml',), '?')
- Finally, we can add an order argument to crudely control the order
+ We can add an order argument to crudely control the order
of execution:
>>> c.action(None, order=99999)
>>> c.actions[-1]
(None, None, (), {}, ('foo.zcml',), '?', 99999)
+ We can also pass an includepath argument, which will be used as the the
+ includepath for the action. (if includepath is None, self.includepath
+ will be used):
+
+ >>> c.action(None, includepath=('abc',))
+ >>> c.actions[-1]
+ (None, None, (), {}, ('abc',), '?')
+
+ We can also pass an info argument, which will be used as the the
+ source line info for the action. (if info is None, self.info will be
+ used):
+
+ >>> c.action(None, info='abc')
+ >>> c.actions[-1]
+ (None, None, (), {}, ('foo.zcml',), 'abc')
+
"""
- action = (discriminator, callable, args, kw,
- getattr(self, 'includepath', ()),
- getattr(self, 'info', ''),
- order,
- )
+ if info is None:
+ info = getattr(self, 'info', '')
+ if includepath is None:
+ includepath = getattr(self, 'includepath', ())
+
+ action = (discriminator, callable, args, kw, includepath, info, order)
+
# remove trailing false items
while (len(action) > 2) and not action[-1]:
action = action[:-1]
Modified: zope.configuration/trunk/src/zope/configuration/interfaces.py
===================================================================
--- zope.configuration/trunk/src/zope/configuration/interfaces.py 2010-12-10 18:19:30 UTC (rev 118793)
+++ zope.configuration/trunk/src/zope/configuration/interfaces.py 2010-12-10 18:38:39 UTC (rev 118794)
@@ -81,7 +81,8 @@
it needs to be procssed.
"""
- def action(self, discriminator, callable, args=(), kw={}, order=0):
+ def action(self, discriminator, callable, args=(), kw={}, order=0,
+ includepath=None, info=None):
"""Record a configuration action
The job of most directives is to compute actions for later
@@ -92,7 +93,9 @@
the discriminator with the value None. An actions with a
discriminator of None never conflicts with other actions. This
is possible to add an order argument to crudely control the
- order of execution
+ order of execution. 'info' is optional source line information,
+ 'includepath' is None (the default) or a tuple of include paths for
+ this action.
"""
def provideFeature(name):
More information about the checkins
mailing list