summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris McDonough <chrism@plope.com>2010-12-09 23:13:04 -0500
committerChris McDonough <chrism@plope.com>2010-12-09 23:13:04 -0500
commitfee38663daccc0130d0c34dbc5a14e67bef2e183 (patch)
tree29090f45f5ee1ffdea77be03af5453518e37ab30
parentcd5e1437ebe1683d5fc71858fa4057a4febcebeb (diff)
downloadpyramid-fee38663daccc0130d0c34dbc5a14e67bef2e183.tar.gz
pyramid-fee38663daccc0130d0c34dbc5a14e67bef2e183.tar.bz2
pyramid-fee38663daccc0130d0c34dbc5a14e67bef2e183.zip
To avoid breaking people's expectations of how ZCML works, we
cannot autocommit ZCML actions incrementally. If we commit actions incrementally, configuration outcome will be controlled purely by ZCML directive execution order, which isn't what anyone who uses ZCML expects. So we don't autocommit each ZCML directive action while parsing is happening, but we do make sure to pass execute=self.autocommit to xmlconfig.file below, which will cause the actions implied by the ZCML that was parsed to be committed right away once parsing is finished if autocommit is True.
-rw-r--r--pyramid/config.py25
1 files changed, 22 insertions, 3 deletions
diff --git a/pyramid/config.py b/pyramid/config.py
index 8b4cb0236..72561c493 100644
--- a/pyramid/config.py
+++ b/pyramid/config.py
@@ -409,11 +409,18 @@ class Configurator(object):
"""
if kw is None:
kw = {}
- if self.autocommit:
+
+ context = self._ctx
+
+ if context is None:
+ autocommit = self.autocommit
+ else:
+ autocommit = context.autocommit
+
+ if autocommit:
if callable is not None:
callable(*args, **kw)
else:
- context = self._ctx
if context is None: # defer expensive creation of context
context = self._ctx = self._make_context(self.autocommit)
if not context.info:
@@ -836,11 +843,23 @@ class Configurator(object):
if context is None:
context = self._ctx = self._make_context(self.autocommit)
+ # To avoid breaking people's expectations of how ZCML works, we
+ # cannot autocommit ZCML actions incrementally. If we commit actions
+ # incrementally, configuration outcome will be controlled purely by
+ # ZCML directive execution order, which isn't what anyone who uses
+ # ZCML expects. So we don't autocommit each ZCML directive action
+ # while parsing is happening, but we do make sure to pass
+ # execute=self.autocommit to xmlconfig.file below, which will cause
+ # the actions implied by the ZCML that was parsed to be committed
+ # right away once parsing is finished if autocommit is True.
+ context = GroupingContextDecorator(context)
+ context.autocommit = False
+
lock.acquire()
try:
context.package = package
xmlconfig.file(filename, package, context=context,
- execute=context.autocommit)
+ execute=self.autocommit)
finally:
lock.release()
self.manager.pop()