[Zope3-checkins] CVS: Zope3/src/zope/app/utility - configure.zcml:1.5.2.1 interfaces.py:1.5.2.1 vocabulary.py:1.2.2.1

Martijn Faassen m.faassen at vet.uu.nl
Tue May 11 05:11:02 EDT 2004


Update of /cvs-repository/Zope3/src/zope/app/utility
In directory cvs.zope.org:/tmp/cvs-serv20906/src/zope/app/utility

Modified Files:
      Tag: faassen-interfaces-branch
	configure.zcml interfaces.py vocabulary.py 
Log Message:
Sync up with changes in HEAD (so I can generate up to date patch file).


=== Zope3/src/zope/app/utility/configure.zcml 1.5 => 1.5.2.1 ===
--- Zope3/src/zope/app/utility/configure.zcml:1.5	Fri Apr 30 12:45:31 2004
+++ Zope3/src/zope/app/utility/configure.zcml	Tue May 11 05:10:30 2004
@@ -1,32 +1,36 @@
 <configure 
-    xmlns="http://namespaces.zope.org/zope"
-    xmlns:fssync="http://namespaces.zope.org/fssync">
+  xmlns="http://namespaces.zope.org/zope"
+  xmlns:fssync="http://namespaces.zope.org/fssync">
 
-<content class=".LocalUtilityService">
-  <factory
-      id="zope.app.services.UtilityService"
-      />
-  <require
-    permission="zope.ManageServices"
-    attributes="queryRegistrations"
-    />
-  <require
+  <content class=".LocalUtilityService">
+    
+    <factory id="zope.app.services.UtilityService" />
+    
+    <require
       permission="zope.ManageServices"
-      interface="zope.app.registration.interfaces.IRegistry"
-      />
-</content>
-
-<content class=".UtilityRegistration">
-  <require
-    permission="zope.ManageServices"
-    interface="zope.app.utility.interfaces.IUtilityRegistration"
-    set_schema="zope.app.utility.interfaces.IUtilityRegistration"
-    />
- </content>
+      attributes="queryRegistrations" />
+      
+    <require
+      permission="zope.ManageServices"
+      interface="zope.app.registration.interfaces.IRegistry" />
+      
+  </content>
 
-<fssync:adapter
+  <content class=".UtilityRegistration">
+    
+    <require
+      permission="zope.ManageServices"
+      interface="zope.app.utility.interfaces.IUtilityRegistration"
+      set_schema="zope.app.utility.interfaces.IUtilityRegistration" />
+      
+   </content>
+  
+  <fssync:adapter
     class=".UtilityRegistration"
-    factory="zope.app.registration.registration.ComponentRegistrationAdapter"
-    />
+    factory="zope.app.registration.registration.ComponentRegistrationAdapter" />
+    
+  <vocabulary
+    name="Utility Component Interfaces"
+    factory=".vocabulary.UtilityComponentInterfacesVocabulary" />
 
 </configure>


=== Zope3/src/zope/app/utility/interfaces.py 1.5 => 1.5.2.1 ===
--- Zope3/src/zope/app/utility/interfaces.py:1.5	Sat Apr 24 19:17:59 2004
+++ Zope3/src/zope/app/utility/interfaces.py	Tue May 11 05:10:30 2004
@@ -27,8 +27,7 @@
         zope.component.interfaces.IUtilityService,
         IRegistry,
         ):
-    """Local Utility Service
-    """
+    """Local Utility Service."""
 
 class IUtilityRegistration(IComponentRegistration):
     """Utility registration object.
@@ -46,11 +45,11 @@
         )
 
     interface = Choice(
-        title = _("Provided interface"),
-        description = _("The interface provided by the utility"),
-        vocabulary="Object Interfaces",
-        readonly = True,
-        required = True,
+        title=_("Provided interface"),
+        description=_("The interface provided by the utility"),
+        vocabulary="Utility Component Interfaces",
+        readonly=True,
+        required=True,
         )
 
     componentPath = ComponentPath(


=== Zope3/src/zope/app/utility/vocabulary.py 1.2 => 1.2.2.1 ===
--- Zope3/src/zope/app/utility/vocabulary.py:1.2	Mon Apr 26 19:58:41 2004
+++ Zope3/src/zope/app/utility/vocabulary.py	Tue May 11 05:10:30 2004
@@ -13,7 +13,7 @@
 ##############################################################################
 """Utility Vocabulary.
 
-This vocabulary provides terms for all utilities providing a given interface. 
+This vocabulary provides terms for all utilities providing a given interface.
 
 $Id$
 """
@@ -25,6 +25,9 @@
 from zope.schema.interfaces import ITokenizedTerm
 
 from zope.app import zapi
+from zope.app.interface.vocabulary import ObjectInterfacesVocabulary
+
+from interfaces import IUtilityRegistration
 
 
 class UtilityQuery(object):
@@ -123,7 +126,7 @@
     False
 
     We can also create a lazy iterator. Note that the utility terms might
-    appear in a different order than the utilities were registered. 
+    appear in a different order than the utilities were registered.
 
     >>> iterator = iter(vocab)
     >>> terms = list(iterator)
@@ -184,7 +187,7 @@
     Sometimes it is desirable to only select the name of a utility. For
     this purpose a 'nameOnly' argument was added to the constructor, in which
     case the UtilityTerm's value is not the utility itself but the name of the
-    utility.  
+    utility.
 
     >>> vocab = UtilityVocabulary(None, IObject, nameOnly=True)
     >>> pprint.pprint([term.value for term in vocab])
@@ -196,12 +199,12 @@
     def __init__(self, context, interface, nameOnly=False):
         if nameOnly is not False:
             nameOnly = True
-        if isinstance(interface, (str, unicode)): 
+        if isinstance(interface, (str, unicode)):
             interface = zapi.getUtility(context, IInterface, interface)
         utils = zapi.getUtilitiesFor(context, interface)
         self._terms = dict([(name, UtilityTerm(nameOnly and name or util, name))
                             for name, util in utils])
-      
+
     def __contains__(self, value):
         """See zope.schema.interfaces.IBaseVocabulary"""
         return value in [term.value for term in self._terms.values()]
@@ -232,3 +235,12 @@
     def __len__(self):
         """See zope.schema.interfaces.IIterableVocabulary"""
         return len(self._terms)
+
+
+class UtilityComponentInterfacesVocabulary(ObjectInterfacesVocabulary):
+
+    def __init__(self, context):
+        if IUtilityRegistration.providedBy(context):
+            context = context.getComponent()
+        super(UtilityComponentInterfacesVocabulary, self).__init__(
+            context)




More information about the Zope3-Checkins mailing list