summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris McDonough <chrism@plope.com>2011-12-02 13:19:59 -0500
committerChris McDonough <chrism@plope.com>2011-12-02 13:19:59 -0500
commit73b206decf517c806fb16de4b7e3b404e596b81c (patch)
tree34554a03c0ed964a5972a98b9b4015ffa8a44e89
parentae0ff29c220bf7f4cd253ae94855c3a33bf2a497 (diff)
downloadpyramid-73b206decf517c806fb16de4b7e3b404e596b81c.tar.gz
pyramid-73b206decf517c806fb16de4b7e3b404e596b81c.tar.bz2
pyramid-73b206decf517c806fb16de4b7e3b404e596b81c.zip
fbo pyramid_zcml: default order back to 0, don't rely on existence of introspectables
-rw-r--r--pyramid/config/__init__.py12
-rw-r--r--pyramid/tests/test_config/test_init.py30
2 files changed, 22 insertions, 20 deletions
diff --git a/pyramid/config/__init__.py b/pyramid/config/__init__.py
index ff0e3581d..40f061897 100644
--- a/pyramid/config/__init__.py
+++ b/pyramid/config/__init__.py
@@ -497,7 +497,7 @@ class Configurator(
info = ActionInfo('<unknown>', 0, '<unknown>', '<unknown>')
return info
- def action(self, discriminator, callable=None, args=(), kw=None, order=None,
+ def action(self, discriminator, callable=None, args=(), kw=None, order=0,
introspectables=()):
""" Register an action which will be executed when
:meth:`pyramid.config.Configurator.commit` is called (or executed
@@ -920,7 +920,7 @@ class ActionState(object):
self._seen_files.add(spec)
return True
- def action(self, discriminator, callable=None, args=(), kw=None, order=None,
+ def action(self, discriminator, callable=None, args=(), kw=None, order=0,
includepath=(), info=None, introspectables=()):
"""Add an action with the given discriminator, callable and arguments
"""
@@ -992,7 +992,9 @@ class ActionState(object):
args = action['args']
kw = action['kw']
info = action['info']
- introspectables = action['introspectables']
+ # we use "get" below in case an action was added via a ZCML
+ # directive that did not know about introspectables
+ introspectables = action.get('introspectables', ())
try:
if callable is not None:
@@ -1037,7 +1039,7 @@ def resolveConflicts(actions):
# old-style ZCML tuple action
action = expand_action(*action)
order = action['order']
- if order is None:
+ if not order:
action['order'] = i
discriminator = action['discriminator']
if discriminator is None:
@@ -1076,7 +1078,7 @@ def resolveConflicts(actions):
return output
def expand_action(discriminator, callable=None, args=(), kw=None,
- includepath=(), info=None, order=None, introspectables=()):
+ includepath=(), info=None, order=0, introspectables=()):
if kw is None:
kw = {}
return dict(
diff --git a/pyramid/tests/test_config/test_init.py b/pyramid/tests/test_config/test_init.py
index 86dace822..94ff4348a 100644
--- a/pyramid/tests/test_config/test_init.py
+++ b/pyramid/tests/test_config/test_init.py
@@ -787,7 +787,7 @@ pyramid.tests.test_config.dummy_include2""",
'info': 'abc',
'introspectables': (),
'kw': {'a': 1},
- 'order': None})])
+ 'order': 0})])
def test_action_branching_nonautocommit_without_config_info(self):
config = self._makeOne(autocommit=False)
@@ -807,7 +807,7 @@ pyramid.tests.test_config.dummy_include2""",
'info': 'z',
'introspectables': (),
'kw': {'a': 1},
- 'order': None})])
+ 'order': 0})])
def test_action_branching_nonautocommit_with_introspectables(self):
config = self._makeOne(autocommit=False)
@@ -1443,7 +1443,7 @@ class TestActionState(unittest.TestCase):
'info': None,
'introspectables': (),
'kw': {'x': 1},
- 'order': None}])
+ 'order': 0}])
c.action(None)
self.assertEqual(
c.actions,
@@ -1454,7 +1454,7 @@ class TestActionState(unittest.TestCase):
'info': None,
'introspectables': (),
'kw': {'x': 1},
- 'order': None},
+ 'order': 0},
{'args': (),
'callable': None,
@@ -1463,7 +1463,7 @@ class TestActionState(unittest.TestCase):
'info': None,
'introspectables': (),
'kw': {},
- 'order': None},])
+ 'order': 0},])
def test_action_with_includepath(self):
c = self._makeOne()
@@ -1478,7 +1478,7 @@ class TestActionState(unittest.TestCase):
'info': None,
'introspectables': (),
'kw': {},
- 'order': None}])
+ 'order': 0}])
def test_action_with_info(self):
c = self._makeOne()
@@ -1492,7 +1492,7 @@ class TestActionState(unittest.TestCase):
'info': 'abc',
'introspectables': (),
'kw': {},
- 'order': None}])
+ 'order': 0}])
def test_action_with_includepath_and_info(self):
c = self._makeOne()
@@ -1506,7 +1506,7 @@ class TestActionState(unittest.TestCase):
'info': 'bleh',
'introspectables': (),
'kw': {},
- 'order': None}])
+ 'order': 0}])
def test_action_with_order(self):
c = self._makeOne()
@@ -1537,7 +1537,7 @@ class TestActionState(unittest.TestCase):
'info': None,
'introspectables': (intr,),
'kw': {},
- 'order': None}])
+ 'order': 0}])
def test_processSpec(self):
c = self._makeOne()
@@ -1565,16 +1565,16 @@ class TestActionState(unittest.TestCase):
c = self._makeOne()
c.actions = [
{'discriminator':1, 'callable':f, 'args':(1,), 'kw':{},
- 'order':None, 'includepath':(), 'info':None,
+ 'order':0, 'includepath':(), 'info':None,
'introspectables':()},
{'discriminator':1, 'callable':f, 'args':(11,), 'kw':{},
- 'includepath':('x',), 'order': None, 'info':None,
+ 'includepath':('x',), 'order': 0, 'info':None,
'introspectables':()},
{'discriminator':2, 'callable':f, 'args':(2,), 'kw':{},
- 'order':None, 'includepath':(), 'info':None,
+ 'order':0, 'includepath':(), 'info':None,
'introspectables':()},
{'discriminator':None, 'callable':None, 'args':(), 'kw':{},
- 'order':None, 'includepath':(), 'info':None,
+ 'order':0, 'includepath':(), 'info':None,
'introspectables':()},
]
c.execute_actions()
@@ -1588,7 +1588,7 @@ class TestActionState(unittest.TestCase):
intr = DummyIntrospectable()
c.actions = [
{'discriminator':1, 'callable':f, 'args':(1,), 'kw':{},
- 'order':None, 'includepath':(), 'info':None,
+ 'order':0, 'includepath':(), 'info':None,
'introspectables':(intr,)},
]
introspector = DummyIntrospector()
@@ -1601,7 +1601,7 @@ class TestActionState(unittest.TestCase):
intr = DummyIntrospectable()
c.actions = [
{'discriminator':1, 'callable':None, 'args':(1,), 'kw':{},
- 'order':None, 'includepath':(), 'info':None,
+ 'order':0, 'includepath':(), 'info':None,
'introspectables':(intr,)},
]
introspector = DummyIntrospector()