[Checkins] SVN: five.hashedresource/trunk/ Added a hack to communicate to ZCML whether Zope2 debug-mode is on.

Thomas Lotze tl at gocept.com
Thu Jul 30 03:36:23 EDT 2009


Log message for revision 102370:
  Added a hack to communicate to ZCML whether Zope2 debug-mode is on.

Changed:
  U   five.hashedresource/trunk/CHANGES.txt
  A   five.hashedresource/trunk/src/five/hashedresource/__debug_mode__.py
  U   five.hashedresource/trunk/src/five/hashedresource/__init__.py
  U   five.hashedresource/trunk/src/five/hashedresource/configure.zcml

-=-
Modified: five.hashedresource/trunk/CHANGES.txt
===================================================================
--- five.hashedresource/trunk/CHANGES.txt	2009-07-30 06:20:48 UTC (rev 102369)
+++ five.hashedresource/trunk/CHANGES.txt	2009-07-30 07:36:23 UTC (rev 102370)
@@ -5,7 +5,7 @@
 1.1 (unreleased)
 ================
 
-- Nothing changed yet.
+- Added a hack to communicate to ZCML whether Zope2 debug-mode is on.
 
 
 1.0 (2009-07-27)

Added: five.hashedresource/trunk/src/five/hashedresource/__debug_mode__.py
===================================================================
--- five.hashedresource/trunk/src/five/hashedresource/__debug_mode__.py	                        (rev 0)
+++ five.hashedresource/trunk/src/five/hashedresource/__debug_mode__.py	2009-07-30 07:36:23 UTC (rev 102370)
@@ -0,0 +1,2 @@
+# This is a dummy module whose importability is used to communicate to ZCML
+# whether debug-mode is on.


Property changes on: five.hashedresource/trunk/src/five/hashedresource/__debug_mode__.py
___________________________________________________________________
Added: svn:keywords
   + Id Rev Date
Added: svn:eol-style
   + native

Modified: five.hashedresource/trunk/src/five/hashedresource/__init__.py
===================================================================
--- five.hashedresource/trunk/src/five/hashedresource/__init__.py	2009-07-30 06:20:48 UTC (rev 102369)
+++ five.hashedresource/trunk/src/five/hashedresource/__init__.py	2009-07-30 07:36:23 UTC (rev 102370)
@@ -1 +1,12 @@
-# python package
+import Globals
+import sys
+
+
+# Communicate to ZCML whether debug-mode is on. As ZCML conditions have only
+# two verbs currently ('have' and 'installed') and it doesn't seem to be
+# possible to switch features on and off programmatically, we make a dummy
+# module importable or not depending on debug-mode so ZCML can ask about it
+# using the 'installed' verb.
+
+if not getattr(Globals, 'DevelopmentMode', False):
+    sys.modules['five.hashedresource.__debug_mode__'] = None

Modified: five.hashedresource/trunk/src/five/hashedresource/configure.zcml
===================================================================
--- five.hashedresource/trunk/src/five/hashedresource/configure.zcml	2009-07-30 06:20:48 UTC (rev 102369)
+++ five.hashedresource/trunk/src/five/hashedresource/configure.zcml	2009-07-30 07:36:23 UTC (rev 102370)
@@ -1,11 +1,18 @@
 <configure
   xmlns="http://namespaces.zope.org/zope"
   xmlns:zcml="http://namespaces.zope.org/zcml"
-  xmlns:browser="http://namespaces.zope.org/browser">
+  xmlns:meta="http://namespaces.zope.org/meta">
 
   <include package="z3c.hashedresource" />
 
   <adapter factory=".url.HashingURL" />
+
+  <!-- We need to have accessed the package before this point in order to give
+       the package's init code a chance to tell us about debug-mode. -->
+
+  <meta:provides zcml:condition="installed five.hashedresource.__debug_mode__"
+                 feature="devmode"/>
+
   <adapter zcml:condition="have devmode"
     factory="z3c.hashedresource.hash.ContentsHash"
     for="Products.Five.browser.resource.DirectoryResource"



More information about the Checkins mailing list