Created
November 6, 2012 08:06
-
-
Save mcdonc/4023392 to your computer and use it in GitHub Desktop.
reentrancy
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/pyramid/config/__init__.py b/pyramid/config/__init__.py | |
index 1dc4385..60f42c1 100644 | |
--- a/pyramid/config/__init__.py | |
+++ b/pyramid/config/__init__.py | |
@@ -1061,7 +1061,7 @@ class ActionState(object): | |
""" | |
try: | |
- for action in resolveConflicts(self.actions): | |
+ for action in self.resolve_conficts(): | |
callable = action['callable'] | |
args = action['args'] | |
kw = action['kw'] | |
@@ -1092,6 +1092,19 @@ class ActionState(object): | |
if clear: | |
del self.actions[:] | |
+ def resolve_conflicts(self): | |
+ while 1: | |
+ try: | |
+ actions = resolveConflicts(self.actions) | |
+ except Restart: | |
+ continue | |
+ else: | |
+ break | |
+ return actions | |
+ | |
+class Restart(Exception): | |
+ pass | |
+ | |
# this function is licensed under the ZPL (stolen from Zope) | |
def resolveConflicts(actions): | |
"""Resolve conflicting actions | |
@@ -1103,6 +1116,7 @@ def resolveConflicts(actions): | |
conflicting actions and is unequal to the include paths in the | |
other conflicting actions. | |
""" | |
+ actionlen = len(actions) | |
def orderandpos(v): | |
n, v = v | |
@@ -1146,6 +1160,9 @@ def resolveConflicts(actions): | |
ainfo = (order, i, action) | |
discriminator = undefer(action['discriminator']) | |
+ newactionlen = len(actions) | |
+ if newactionlen != actionlen: | |
+ raise Restart | |
action['discriminator'] = discriminator | |
if discriminator is None: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment