[Zope3-checkins] SVN: Zope3/trunk/ Implemented devmode proposal.

Stephan Richter srichter at cosmos.phy.tufts.edu
Sat Oct 15 13:45:11 EDT 2005


Log message for revision 39467:
  Implemented devmode proposal.
  

Changed:
  U   Zope3/trunk/doc/CHANGES.txt
  U   Zope3/trunk/ftesting.zcml
  U   Zope3/trunk/src/zope/app/apidoc/codemodule/README.txt
  U   Zope3/trunk/src/zope/app/apidoc/codemodule/browser/README.txt
  U   Zope3/trunk/src/zope/app/apidoc/codemodule/browser/configure.zcml
  U   Zope3/trunk/src/zope/app/apidoc/codemodule/browser/tests.py
  U   Zope3/trunk/src/zope/app/apidoc/codemodule/tests.py
  U   Zope3/trunk/src/zope/app/apidoc/configure.zcml
  U   Zope3/trunk/src/zope/app/apidoc/meta.zcml
  U   Zope3/trunk/src/zope/app/appsetup/bootstrap.txt
  U   Zope3/trunk/src/zope/app/appsetup/schema.xml
  U   Zope3/trunk/src/zope/app/preference/configure.zcml
  U   Zope3/trunk/src/zope/app/twisted/main.py
  U   Zope3/trunk/src/zope/app/twisted/schema.xml
  U   Zope3/trunk/src/zope/app/wsgi/__init__.py
  U   Zope3/trunk/src/zope/configuration/xmlconfig.py
  U   Zope3/trunk/zope.conf.in
  U   Zope3/trunk/zopeskel/etc/ftesting.zcml
  U   Zope3/trunk/zopeskel/etc/zope.conf.in

-=-
Modified: Zope3/trunk/doc/CHANGES.txt
===================================================================
--- Zope3/trunk/doc/CHANGES.txt	2005-10-15 12:23:15 UTC (rev 39466)
+++ Zope3/trunk/doc/CHANGES.txt	2005-10-15 17:45:11 UTC (rev 39467)
@@ -10,6 +10,13 @@
 
     New features
 
+      - Implemented the `devmode` switch for `zope.conf`. When turned on a
+        ZCML feature called `devmode` is provided. Packages can then register
+        functionality based on this feature. In Zope 3 itself, the devmode is
+        used to only load the API doc is devmode; turning off the devmode thus
+        closes a potential security hole and increases the start time by more
+        than a second.
+
       - The ZServer has been replaced with the Twisted server. The Twisted
         server supports all that the ZServer supporting has well has HTTP over
         SSL natively and SFTP (disabled for now because of error handling

Modified: Zope3/trunk/ftesting.zcml
===================================================================
--- Zope3/trunk/ftesting.zcml	2005-10-15 12:23:15 UTC (rev 39466)
+++ Zope3/trunk/ftesting.zcml	2005-10-15 17:45:11 UTC (rev 39467)
@@ -1,8 +1,12 @@
-<configure 
+<configure
    xmlns="http://namespaces.zope.org/zope"
+   xmlns:meta="http://namespaces.zope.org/meta"
    i18n_domain="zope"
    >
 
+  <!-- Turn on the devmode -->
+  <meta:provides feature="devmode" />
+
   <!-- This file is the equivalent of site.zcml and it is -->
   <!-- used for functional testing setup -->
 
@@ -24,17 +28,17 @@
 
   <unauthenticatedGroup
     id="zope.Anybody"
-    title="Unauthenticated Users" 
+    title="Unauthenticated Users"
     />
 
   <authenticatedGroup
     id="zope.Authenticated"
-    title="Authenticated Users" 
+    title="Authenticated Users"
     />
 
   <everybodyGroup
     id="zope.Everybody"
-    title="All Users" 
+    title="All Users"
     />
 
   <!-- Principal that tests generally run as -->

Modified: Zope3/trunk/src/zope/app/apidoc/codemodule/README.txt
===================================================================
--- Zope3/trunk/src/zope/app/apidoc/codemodule/README.txt	2005-10-15 12:23:15 UTC (rev 39466)
+++ Zope3/trunk/src/zope/app/apidoc/codemodule/README.txt	2005-10-15 17:45:11 UTC (rev 39467)
@@ -132,7 +132,7 @@
   []
 
   >>> klass.getMethods()[0] #doctest:+NORMALIZE_WHITESPACE
-  ('get', <unbound method APIDocumentation.get>, 
+  ('get', <unbound method APIDocumentation.get>,
    <InterfaceClass zope.interface.common.mapping.IReadMapping>)
 
 
@@ -179,11 +179,11 @@
   >>> class Blah(object):
   ...      zope.interface.implements(IBlah)
   ...
-  ...      def foo(self): 
+  ...      def foo(self):
   ...          pass
-  ...      def bar(self): 
+  ...      def bar(self):
   ...          pass
-  ...      def _blah(self): 
+  ...      def _blah(self):
   ...          pass
 
 Now we create the class documentation wrapper:
@@ -226,7 +226,7 @@
   >>> func.getAttributes()
   []
 
-but this function has none as most functions. So let's create a new function 
+but this function has none as most functions. So let's create a new function
 
   >>> def foo(bar=1):
   ...     pass
@@ -269,9 +269,9 @@
 ZCML file documentation objects present configuration files and parse the file
 content to provide some advanced markup. The object is easily instantiated:
 
-  >>> path = os.path.join(os.path.dirname(codemodule.__file__), 
+  >>> path = os.path.join(os.path.dirname(codemodule.__file__),
   ...                     'configure.zcml')
-  >>> module = codemodule.module.Module(None, 'zope.app.apidoc.codemodule', 
+  >>> module = codemodule.module.Module(None, 'zope.app.apidoc.codemodule',
   ...                                   zope.app.apidoc.codemodule)
 
   >>> zcml = codemodule.zcml.ZCMLFile(path, module)
@@ -309,7 +309,7 @@
 the parser info object,
 
   >>> info = `root.info`
-  
+
   # Windows fix
   >>> info = info.replace('\\', '/')
 
@@ -321,7 +321,7 @@
 the sub-directives,
 
   >>> root.subs[:2]
-  [<Directive (u'http://namespaces.zope.org/zope', u'class')>, 
+  [<Directive (u'http://namespaces.zope.org/zope', u'class')>,
    <Directive (u'http://namespaces.zope.org/zope', u'class')>]
 
 and finally a list of all prefixes.

Modified: Zope3/trunk/src/zope/app/apidoc/codemodule/browser/README.txt
===================================================================
--- Zope3/trunk/src/zope/app/apidoc/codemodule/browser/README.txt	2005-10-15 12:23:15 UTC (rev 39466)
+++ Zope3/trunk/src/zope/app/apidoc/codemodule/browser/README.txt	2005-10-15 17:45:11 UTC (rev 39467)
@@ -23,7 +23,7 @@
 process to get a module documentation object:
 
   >>> details = browser.module.ModuleDetails()
-  >>> details.context = zapi.traverse(cm, 
+  >>> details.context = zapi.traverse(cm,
   ...     'zope/app/apidoc/codemodule/codemodule')
   >>> from zope.publisher.browser import TestRequest
   >>> details.request = TestRequest()
@@ -192,7 +192,7 @@
 documentation component:
 
   >>> details = browser.function.FunctionDetails()
-  >>> details.context = zapi.traverse(cm, 
+  >>> details.context = zapi.traverse(cm,
   ...     'zope/app/apidoc/codemodule/browser/tests/foo')
   >>> details.request = TestRequest()
 
@@ -226,7 +226,7 @@
 documentation component:
 
   >>> details = browser.text.TextFileDetails()
-  >>> details.context = zapi.traverse(cm, 
+  >>> details.context = zapi.traverse(cm,
   ...     'zope/app/apidoc/codemodule/README.txt')
   >>> details.request = TestRequest()
 
@@ -249,7 +249,7 @@
 provide all the view content:
 
   >>> details = browser.zcml.DirectiveDetails()
-  >>> zcml = zapi.traverse(cm, 
+  >>> zcml = zapi.traverse(cm,
   ...     'zope/app/apidoc/codemodule/configure.zcml')
   >>> details.context = zcml.rootElement
   >>> details.request = TestRequest()

Modified: Zope3/trunk/src/zope/app/apidoc/codemodule/browser/configure.zcml
===================================================================
--- Zope3/trunk/src/zope/app/apidoc/codemodule/browser/configure.zcml	2005-10-15 12:23:15 UTC (rev 39466)
+++ Zope3/trunk/src/zope/app/apidoc/codemodule/browser/configure.zcml	2005-10-15 17:45:11 UTC (rev 39467)
@@ -9,13 +9,13 @@
       class=".menu.Menu"
       name="menu.html"
       template="menu.pt" />
-      
+
   <page
       for="..codemodule.CodeModule"
       permission="zope.app.apidoc.UseAPIDoc"
       class=".menu.Menu"
       name="staticmenu.html"
-      template="static_menu.pt" />      
+      template="static_menu.pt" />
 
   <page
       for="..interfaces.IModuleDocumentation"

Modified: Zope3/trunk/src/zope/app/apidoc/codemodule/browser/tests.py
===================================================================
--- Zope3/trunk/src/zope/app/apidoc/codemodule/browser/tests.py	2005-10-15 12:23:15 UTC (rev 39466)
+++ Zope3/trunk/src/zope/app/apidoc/codemodule/browser/tests.py	2005-10-15 17:45:11 UTC (rev 39467)
@@ -47,7 +47,10 @@
 foo.deprecated = True
 
 meta = '''
-<configure i18n_domain="zope">
+<configure
+    xmlns:meta="http://namespaces.zope.org/meta"
+    i18n_domain="zope">
+  <meta:provides feature="devmode" />
   <include package="zope.app" file="meta.zcml" />
   <include package="zope.app.apidoc" file="meta.zcml" />
   <include package="zope.app" file="menus.zcml" />
@@ -74,8 +77,8 @@
 
     # Register Renderer Components
     ztapi.provideUtility(IFactory, ReStructuredTextSourceFactory,
-                         'zope.source.rest')    
-    ztapi.browserView(IReStructuredTextSource, '', 
+                         'zope.source.rest')
+    ztapi.browserView(IReStructuredTextSource, '',
                       ReStructuredTextToHTMLRenderer)
     # Cheat and register the ReST factory for STX as well.
     ztapi.provideUtility(IFactory, ReStructuredTextSourceFactory,
@@ -98,8 +101,8 @@
 def tearDown(test):
     placelesssetup.tearDown()
     global old_context, old_source_file
-    zope.app.appsetup.appsetup.__config_context = old_context    
-    zope.app.appsetup.appsetup.__config_source = old_source_file    
+    zope.app.appsetup.appsetup.__config_context = old_context
+    zope.app.appsetup.appsetup.__config_source = old_source_file
 
 
 def test_suite():

Modified: Zope3/trunk/src/zope/app/apidoc/codemodule/tests.py
===================================================================
--- Zope3/trunk/src/zope/app/apidoc/codemodule/tests.py	2005-10-15 12:23:15 UTC (rev 39466)
+++ Zope3/trunk/src/zope/app/apidoc/codemodule/tests.py	2005-10-15 17:45:11 UTC (rev 39467)
@@ -29,6 +29,7 @@
 
     meta = os.path.join(os.path.dirname(zope.app.__file__), 'meta.zcml')
     context = xmlconfig.file(meta, zope.app)
+    context.provideFeature('devmode')
     meta = os.path.join(os.path.dirname(zope.app.apidoc.__file__), 'meta.zcml')
     context = xmlconfig.file(meta, zope.app.apidoc, context)
 
@@ -40,7 +41,7 @@
 def tearDown(test):
     placelesssetup.tearDown()
     global old_context
-    zope.app.appsetup.appsetup.__config_context = old_context    
+    zope.app.appsetup.appsetup.__config_context = old_context
 
 
 def test_suite():

Modified: Zope3/trunk/src/zope/app/apidoc/configure.zcml
===================================================================
--- Zope3/trunk/src/zope/app/apidoc/configure.zcml	2005-10-15 12:23:15 UTC (rev 39466)
+++ Zope3/trunk/src/zope/app/apidoc/configure.zcml	2005-10-15 17:45:11 UTC (rev 39467)
@@ -1,6 +1,8 @@
 <configure
   xmlns="http://namespaces.zope.org/zope"
   xmlns:apidoc="http://namespaces.zope.org/apidoc"
+  xmlns:zcml="http://namespaces.zope.org/zcml"
+  zcml:condition="have devmode"
   i18n_domain="zope">
 
   <permission
@@ -28,35 +30,35 @@
 
   <!-- Register Public API Dcoumentation -->
 
-  <apidoc:bookchapter 
+  <apidoc:bookchapter
       id="inspect"
       title="Inspection API"
       />
-  <apidoc:bookchapter 
+  <apidoc:bookchapter
       id="interface"
       title="Interfaces"
       doc_path="interface.txt"
       parent="inspect"
       />
-  <apidoc:bookchapter 
+  <apidoc:bookchapter
       id="component"
       title="Components"
       doc_path="component.txt"
       parent="inspect"
       />
-  <apidoc:bookchapter 
+  <apidoc:bookchapter
       id="presentation"
       title="Presentation"
       doc_path="presentation.txt"
       parent="inspect"
       />
-  <apidoc:bookchapter 
+  <apidoc:bookchapter
       id="misc"
       title="Miscellaneous"
       doc_path="utilities.txt"
       parent="inspect"
       />
-  <apidoc:bookchapter 
+  <apidoc:bookchapter
       id="classregistry"
       title="Class Registry"
       doc_path="classregistry.txt"
@@ -67,7 +69,7 @@
 
   <preferenceGroup
       id="apidoc"
-      title="API Doc Tool" 
+      title="API Doc Tool"
       description="
          These are all the preferences related to viewing the API
          documentation."

Modified: Zope3/trunk/src/zope/app/apidoc/meta.zcml
===================================================================
--- Zope3/trunk/src/zope/app/apidoc/meta.zcml	2005-10-15 12:23:15 UTC (rev 39466)
+++ Zope3/trunk/src/zope/app/apidoc/meta.zcml	2005-10-15 17:45:11 UTC (rev 39467)
@@ -1,4 +1,7 @@
-<configure xmlns:meta="http://namespaces.zope.org/meta">
+<configure
+    xmlns:meta="http://namespaces.zope.org/meta"
+    xmlns:zcml="http://namespaces.zope.org/zcml"
+    zcml:condition="have devmode">
   <include package=".codemodule" file="meta.zcml"/>
   <include package=".bookmodule" file="meta.zcml"/>
   <meta:provides feature="apidoc" />

Modified: Zope3/trunk/src/zope/app/appsetup/bootstrap.txt
===================================================================
--- Zope3/trunk/src/zope/app/appsetup/bootstrap.txt	2005-10-15 12:23:15 UTC (rev 39466)
+++ Zope3/trunk/src/zope/app/appsetup/bootstrap.txt	2005-10-15 17:45:11 UTC (rev 39467)
@@ -21,7 +21,7 @@
     >>> root = conn.root()[ZopePublication.root_name]
     >>> sm = root.getSiteManager()
     >>> conn.close()
-    
+
 A DatabaseOpenedWithRoot is generated with the database.
 
     >>> from zope.app.event.tests.placelesssetup import getEvents

Modified: Zope3/trunk/src/zope/app/appsetup/schema.xml
===================================================================
--- Zope3/trunk/src/zope/app/appsetup/schema.xml	2005-10-15 12:23:15 UTC (rev 39466)
+++ Zope3/trunk/src/zope/app/appsetup/schema.xml	2005-10-15 17:45:11 UTC (rev 39467)
@@ -54,4 +54,17 @@
     </description>
     <metadefault>$softwarehome/src</metadefault>
   </multikey>
+
+  <key name="devmode" datatype="boolean">
+    <description>
+      Switches the Developer Mode on and off.
+
+      In developer mode, the Web UI will provide usefull utilities for
+      developers to work on Zope 3 applications.
+    </description>
+    <example>
+      devmode on
+    </example>
+    <metadefault>off</metadefault>
+  </key>
 </schema>

Modified: Zope3/trunk/src/zope/app/preference/configure.zcml
===================================================================
--- Zope3/trunk/src/zope/app/preference/configure.zcml	2005-10-15 12:23:15 UTC (rev 39466)
+++ Zope3/trunk/src/zope/app/preference/configure.zcml	2005-10-15 17:45:11 UTC (rev 39467)
@@ -6,7 +6,7 @@
   i18n_domain="zope">
 
   <view
-      name="preferences" 
+      name="preferences"
       for="*"
       type="*"
       provides="zope.app.traversing.interfaces.ITraversable"
@@ -29,7 +29,7 @@
   <!-- Root preference group -->
   <preferenceGroup
       id=""
-      title="User Preferences" 
+      title="User Preferences"
       />
 
 
@@ -60,7 +60,7 @@
   </localUtility>
 
   <view
-      name="preferences" 
+      name="preferences"
       for=".interfaces.IDefaultPreferenceProvider"
       type="*"
       provides="zope.interface.Interface"
@@ -90,9 +90,9 @@
       name="preferences_macros"
       permission="zope.View"
       class=".browser.PreferencesMacros"
-      allowed_interface="zope.interface.common.mapping.IItemMapping" 
+      allowed_interface="zope.interface.common.mapping.IItemMapping"
       />
-  
+
   <browser:page
       for="*"
       name="preference_macro_definitions"
@@ -108,12 +108,12 @@
       for=".interfaces.IPreferenceGroup"
       class=".browser.PreferencesTree"
       permission="zope.View"
-      attribute="tree" 
+      attribute="tree"
       />
 
   <!-- Book Chapter -->
 
-  <apidoc:bookchapter 
+  <apidoc:bookchapter
       id="preferences"
       title="User Preferences API"
       doc_path="README.txt"

Modified: Zope3/trunk/src/zope/app/twisted/main.py
===================================================================
--- Zope3/trunk/src/zope/app/twisted/main.py	2005-10-15 12:23:15 UTC (rev 39466)
+++ Zope3/trunk/src/zope/app/twisted/main.py	2005-10-15 17:45:11 UTC (rev 39467)
@@ -110,9 +110,13 @@
     observer = log.CommonAccessLoggingObserver()
     observer.start()
 
-    zope.app.appsetup.config(options.site_definition,
-                             features=('twisted',))
+    features = ('twisted',)
+    # Provide the devmode, if activated
+    if options.devmode:
+        features += ('devmode',)
 
+    zope.app.appsetup.config(options.site_definition, features=features)
+
     db = zope.app.appsetup.appsetup.multi_database(options.databases)[0][0]
 
     notify(zope.app.appsetup.interfaces.DatabaseOpened(db))

Modified: Zope3/trunk/src/zope/app/twisted/schema.xml
===================================================================
--- Zope3/trunk/src/zope/app/twisted/schema.xml	2005-10-15 12:23:15 UTC (rev 39466)
+++ Zope3/trunk/src/zope/app/twisted/schema.xml	2005-10-15 17:45:11 UTC (rev 39467)
@@ -58,4 +58,5 @@
       for internal purposes.
     </description>
   </key>
+
 </schema>

Modified: Zope3/trunk/src/zope/app/wsgi/__init__.py
===================================================================
--- Zope3/trunk/src/zope/app/wsgi/__init__.py	2005-10-15 12:23:15 UTC (rev 39466)
+++ Zope3/trunk/src/zope/app/wsgi/__init__.py	2005-10-15 17:45:11 UTC (rev 39467)
@@ -93,6 +93,10 @@
     # Setup the event log
     options.eventlog()
 
+    # Insert the devmode feature, if turned on
+    if options.devmode:
+        features += ('devmode',)
+
     # Configure the application
     appsetup.config(options.site_definition, features=features)
 

Modified: Zope3/trunk/src/zope/configuration/xmlconfig.py
===================================================================
--- Zope3/trunk/src/zope/configuration/xmlconfig.py	2005-10-15 12:23:15 UTC (rev 39466)
+++ Zope3/trunk/src/zope/configuration/xmlconfig.py	2005-10-15 17:45:11 UTC (rev 39467)
@@ -167,7 +167,7 @@
             if lines[0][:column].strip():
                 # Remove text before start if it's noy whitespace
                 lines[0] = lines[0][self.column:]
-                
+
             src = ''.join([u"  "+l for l in lines])
 
         return "%s\n%s" % (`self`, src)
@@ -427,13 +427,13 @@
         include:
 
         - ``*`` matches 0 or more characters
-        
+
         - ``?`` matches a single character
-        
-        - ``[<seq>]`` matches any character in seq 
-        
-        - ``[!<seq>]`` matches any character not in seq 
 
+        - ``[<seq>]`` matches any character in seq
+
+        - ``[!<seq>]`` matches any character not in seq
+
         The file names are included in sorted order, where sorting is
         without regard to case.
         """,
@@ -476,7 +476,7 @@
         paths = [path for (l, path) in paths]
     else:
         paths = [context.path(file)]
-    
+
     for path in paths:
         if context.processFile(path):
             f = openInOrPlain(path)

Modified: Zope3/trunk/zope.conf.in
===================================================================
--- Zope3/trunk/zope.conf.in	2005-10-15 12:23:15 UTC (rev 39466)
+++ Zope3/trunk/zope.conf.in	2005-10-15 17:45:11 UTC (rev 39467)
@@ -79,3 +79,12 @@
     path STDOUT
   </logfile>
 </eventlog>
+
+# devmode
+#
+#   Switches the Developer Mode on and off.
+#
+# Default:
+#   devmode off
+#
+devmode on

Modified: Zope3/trunk/zopeskel/etc/ftesting.zcml
===================================================================
--- Zope3/trunk/zopeskel/etc/ftesting.zcml	2005-10-15 12:23:15 UTC (rev 39466)
+++ Zope3/trunk/zopeskel/etc/ftesting.zcml	2005-10-15 17:45:11 UTC (rev 39467)
@@ -1,8 +1,12 @@
-<configure 
+<configure
    xmlns="http://namespaces.zope.org/zope"
+   xmlns:meta="http://namespaces.zope.org/meta"
    i18n_domain="zope"
    >
 
+  <!-- Turn on the devmode -->
+  <meta:provides feature="devmode" />
+
   <!-- This file is the equivalent of site.zcml and it is -->
   <!-- used for functional testing setup -->
 
@@ -24,17 +28,17 @@
 
   <unauthenticatedGroup
     id="zope.Anybody"
-    title="Unauthenticated Users" 
+    title="Unauthenticated Users"
     />
 
   <authenticatedGroup
     id="zope.Authenticated"
-    title="Authenticated Users" 
+    title="Authenticated Users"
     />
 
   <everybodyGroup
     id="zope.Everybody"
-    title="All Users" 
+    title="All Users"
     />
 
   <!-- Principal that tests generally run as -->

Modified: Zope3/trunk/zopeskel/etc/zope.conf.in
===================================================================
--- Zope3/trunk/zopeskel/etc/zope.conf.in	2005-10-15 12:23:15 UTC (rev 39466)
+++ Zope3/trunk/zopeskel/etc/zope.conf.in	2005-10-15 17:45:11 UTC (rev 39467)
@@ -109,3 +109,12 @@
     path STDOUT
   </logfile>
 </eventlog>
+
+# devmode
+#
+#   Switches the Developer Mode on and off.
+#
+# Default:
+#   devmode off
+#
+devmode on



More information about the Zope3-Checkins mailing list