[Checkins] SVN: z3c.baseregistry/trunk/ Fix management form crash, when working with non-root local sites.

Dan Korostelev nadako at gmail.com
Wed Mar 4 18:39:58 EST 2009


Log message for revision 97499:
  Fix management form crash, when working with non-root local sites.
  
  Remove unused dependencies, use zope.site instead of zope.app.component.
  
  TODO: move ZMI stuff into extra dependency or, better, another package.

Changed:
  U   z3c.baseregistry/trunk/CHANGES.txt
  U   z3c.baseregistry/trunk/setup.py
  U   z3c.baseregistry/trunk/src/z3c/baseregistry/README.txt
  D   z3c.baseregistry/trunk/src/z3c/baseregistry/SETUP.cfg
  U   z3c.baseregistry/trunk/src/z3c/baseregistry/browser/README.txt
  U   z3c.baseregistry/trunk/src/z3c/baseregistry/browser/base.py
  U   z3c.baseregistry/trunk/src/z3c/baseregistry/browser/configure.zcml
  D   z3c.baseregistry/trunk/src/z3c/baseregistry/z3c.baseregistry-meta.zcml
  D   z3c.baseregistry/trunk/src/z3c/baseregistry/z3c.baseregistry.browser-configure.zcml
  D   z3c.baseregistry/trunk/src/z3c/baseregistry/z3c.baseregistry.browser-ftesting.zcml

-=-
Modified: z3c.baseregistry/trunk/CHANGES.txt
===================================================================
--- z3c.baseregistry/trunk/CHANGES.txt	2009-03-04 23:29:00 UTC (rev 97498)
+++ z3c.baseregistry/trunk/CHANGES.txt	2009-03-04 23:39:58 UTC (rev 97499)
@@ -2,7 +2,18 @@
 CHANGES
 =======
 
-Version 1.0.0 (2008-01-24)
---------------------------
+1.1.0 (unreleased)
+------------------
 
+- Fix base registry management form failure in case, when a site has its
+  parent's local site manager (that isn't registered as utility) in its
+  __bases__.
+
+- Use zope.site instead of zope.app.component.
+
+- Drop unused dependencies on zope.app.i18n and zope.app.pagetemplate.
+
+1.0.0 (2008-01-24)
+------------------
+
 - Initial Release

Modified: z3c.baseregistry/trunk/setup.py
===================================================================
--- z3c.baseregistry/trunk/setup.py	2009-03-04 23:29:00 UTC (rev 97498)
+++ z3c.baseregistry/trunk/setup.py	2009-03-04 23:39:58 UTC (rev 97499)
@@ -23,7 +23,7 @@
 
 setup (
     name = "z3c.baseregistry",
-    version = "1.0.1dev",
+    version = "1.1.0dev",
     author = "Stephan Richter, Roger Ineichen and the Zope Community",
     author_email = "zope-dev at zope.org",
     description = "Manage IComponents instances using Python code and ZCML.",
@@ -62,15 +62,13 @@
         ),
     install_requires = [
         'setuptools',
-        'zope.app.component',
-        'zope.app.i18n',
-        'zope.app.pagetemplate',
         'zope.component',
         'zope.configuration',
         'zope.formlib',
         'zope.i18nmessageid',
         'zope.interface',
         'zope.schema',
+        'zope.site',
         ],
     zip_safe = False,
 )

Modified: z3c.baseregistry/trunk/src/z3c/baseregistry/README.txt
===================================================================
--- z3c.baseregistry/trunk/src/z3c/baseregistry/README.txt	2009-03-04 23:29:00 UTC (rev 97498)
+++ z3c.baseregistry/trunk/src/z3c/baseregistry/README.txt	2009-03-04 23:39:58 UTC (rev 97499)
@@ -105,9 +105,9 @@
   >>> cPickle.loads(jar)
   Traceback (most recent call last):
   ...
-  ComponentLookupError: (<zope.component.interfaces.ComponentLookupError ...>,
-                         <function BC at ...>,
-                         (<BaseGlobalComponents base>, 'myRegistry'))
+  ComponentLookupError: (ComponentLookupError(<InterfaceClass zope.component.interfaces.IComponents>, 'myRegistry'),
+                        <function BC at 0x...>,
+                        (<BaseGlobalComponents base>, 'myRegistry'))
 
 This is because we have not registered the registry in its parent as an
 ``IComponents`` utility, yet:
@@ -270,10 +270,10 @@
 Most commonly base registries will be used in local site managers. So let's
 create a local site:
 
-  >>> from zope.app.folder import Folder
+  >>> from zope.site.folder import Folder
   >>> site = Folder()
 
-  >>> from zope.app.component.site import LocalSiteManager
+  >>> from zope.site.site import LocalSiteManager
   >>> site.setSiteManager(LocalSiteManager(site))
   >>> sm = site.getSiteManager()
 

Deleted: z3c.baseregistry/trunk/src/z3c/baseregistry/SETUP.cfg
===================================================================
--- z3c.baseregistry/trunk/src/z3c/baseregistry/SETUP.cfg	2009-03-04 23:29:00 UTC (rev 97498)
+++ z3c.baseregistry/trunk/src/z3c/baseregistry/SETUP.cfg	2009-03-04 23:39:58 UTC (rev 97499)
@@ -1,4 +0,0 @@
-<data-files zopeskel/etc/package-includes>
-  z3c.baseregistry-*.zcml
-  z3c.baseregistry.browser-*.zcml
-</data-files>

Modified: z3c.baseregistry/trunk/src/z3c/baseregistry/browser/README.txt
===================================================================
--- z3c.baseregistry/trunk/src/z3c/baseregistry/browser/README.txt	2009-03-04 23:29:00 UTC (rev 97498)
+++ z3c.baseregistry/trunk/src/z3c/baseregistry/browser/README.txt	2009-03-04 23:39:58 UTC (rev 97499)
@@ -15,7 +15,7 @@
 behavior of calling from within the root folder:
 
   >>> import zope.component
-  >>> from zope.app.component import hooks
+  >>> from zope.site import hooks
 
   >>> site = getRootFolder()
   >>> hooks.setSite(site)

Modified: z3c.baseregistry/trunk/src/z3c/baseregistry/browser/base.py
===================================================================
--- z3c.baseregistry/trunk/src/z3c/baseregistry/browser/base.py	2009-03-04 23:29:00 UTC (rev 97498)
+++ z3c.baseregistry/trunk/src/z3c/baseregistry/browser/base.py	2009-03-04 23:39:58 UTC (rev 97499)
@@ -20,22 +20,41 @@
 import zope.component
 import zope.schema
 from zope.i18nmessageid import ZopeMessageFactory as _
-from zope.app.component import vocabulary
-from zope.app.pagetemplate import ViewPageTemplateFile
 from zope.formlib import form
+from zope.security.proxy import removeSecurityProxy
+from zope.site.interfaces import ILocalSiteManager
 
 BASENAME = _('-- Global Base Registry --')
+PARENTNAME = _('-- Parent Local Registry --')
 
-class BaseComponentsVocabulary(vocabulary.UtilityVocabulary):
+class BaseComponentsVocabulary(zope.schema.vocabulary.SimpleVocabulary):
     """A vocabulary for ``IComponents`` utilities."""
 
-    interface = zope.component.interfaces.IComponents
+    zope.interface.classProvides(zope.schema.interfaces.IVocabularyFactory)
 
-    def __init__(self, context, **kw):
-        super(BaseComponentsVocabulary, self).__init__(context, **kw)
-        self._terms[BASENAME] = vocabulary.UtilityTerm(
-            zope.component.globalregistry.base, BASENAME)
+    def __init__(self, context):
+        terms = []
+        utils = set()
+        
+        # add available registry utilities
+        for name, util in \
+            zope.component.getUtilitiesFor(
+                zope.component.interfaces.IComponents, context):
+            
+            terms.append(zope.schema.vocabulary.SimpleTerm(util, name))
+            utils.add(util)
 
+        # add location parent registry if any
+        lsm = [removeSecurityProxy(sm) for sm in context.__bases__ \
+               if sm not in utils and ILocalSiteManager.providedBy(sm)]
+        if lsm:
+            terms.append(zope.schema.vocabulary.SimpleTerm(lsm[0], PARENTNAME))
+
+        # add the base registry
+        terms.append(zope.schema.vocabulary.SimpleTerm(zope.component.globalregistry.base, BASENAME))
+        
+        super(BaseComponentsVocabulary, self).__init__(terms)
+
 class IComponentsBases(zope.interface.Interface):
     """An interface describing the bases API of the IComponents object."""
 

Modified: z3c.baseregistry/trunk/src/z3c/baseregistry/browser/configure.zcml
===================================================================
--- z3c.baseregistry/trunk/src/z3c/baseregistry/browser/configure.zcml	2009-03-04 23:29:00 UTC (rev 97498)
+++ z3c.baseregistry/trunk/src/z3c/baseregistry/browser/configure.zcml	2009-03-04 23:39:58 UTC (rev 97499)
@@ -9,7 +9,7 @@
       name="Base Components"
       />
 
-  <class class="zope.app.component.site.LocalSiteManager">
+  <class class="zope.site.site.LocalSiteManager">
     <implements interface=".base.IComponentsBases" />
     <require
         permission="zope.Public"
@@ -21,7 +21,7 @@
 
   <browser:page
       name="setBases.html"
-      for="zope.app.component.interfaces.ILocalSiteManager"
+      for="zope.site.interfaces.ILocalSiteManager"
       class=".base.SetBasesPage"
       permission="zope.ManageSite"
       menu="zmi_views" title="Bases"

Deleted: z3c.baseregistry/trunk/src/z3c/baseregistry/z3c.baseregistry-meta.zcml
===================================================================
--- z3c.baseregistry/trunk/src/z3c/baseregistry/z3c.baseregistry-meta.zcml	2009-03-04 23:29:00 UTC (rev 97498)
+++ z3c.baseregistry/trunk/src/z3c/baseregistry/z3c.baseregistry-meta.zcml	2009-03-04 23:39:58 UTC (rev 97499)
@@ -1 +0,0 @@
-<include package="z3c.baseregistry" file="meta.zcml" />

Deleted: z3c.baseregistry/trunk/src/z3c/baseregistry/z3c.baseregistry.browser-configure.zcml
===================================================================
--- z3c.baseregistry/trunk/src/z3c/baseregistry/z3c.baseregistry.browser-configure.zcml	2009-03-04 23:29:00 UTC (rev 97498)
+++ z3c.baseregistry/trunk/src/z3c/baseregistry/z3c.baseregistry.browser-configure.zcml	2009-03-04 23:39:58 UTC (rev 97499)
@@ -1 +0,0 @@
-<include package="z3c.baseregistry.browser" />

Deleted: z3c.baseregistry/trunk/src/z3c/baseregistry/z3c.baseregistry.browser-ftesting.zcml
===================================================================
--- z3c.baseregistry/trunk/src/z3c/baseregistry/z3c.baseregistry.browser-ftesting.zcml	2009-03-04 23:29:00 UTC (rev 97498)
+++ z3c.baseregistry/trunk/src/z3c/baseregistry/z3c.baseregistry.browser-ftesting.zcml	2009-03-04 23:39:58 UTC (rev 97499)
@@ -1 +0,0 @@
-<include package="z3c.baseregistry.browser" file="ftesting.zcml" />



More information about the Checkins mailing list