[Zope3-checkins] CVS: Zope3/src/zope/app/renderer - __init__.py:1.4 vocabulary.py:1.4

Stephan Richter srichter at cosmos.phy.tufts.edu
Tue Mar 9 07:39:40 EST 2004


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

Modified Files:
	__init__.py vocabulary.py 
Log Message:


Adjusted code to use utility service to look up factories or use the new zapi
methods.




=== Zope3/src/zope/app/renderer/__init__.py 1.3 => 1.4 ===
--- Zope3/src/zope/app/renderer/__init__.py:1.3	Tue Mar  2 09:24:45 2004
+++ Zope3/src/zope/app/renderer/__init__.py	Tue Mar  9 07:39:08 2004
@@ -29,8 +29,10 @@
     """Creates an ISource object."""
     implements(IFactory)
 
-    def __init__(self, iface):
+    def __init__(self, iface, title='', description=''):
         self._iface = iface
+        self.title = title
+        self.description = description
 
     def getInterfaces(self):
         return Declaration(self._iface).flattened()


=== Zope3/src/zope/app/renderer/vocabulary.py 1.3 => 1.4 ===
--- Zope3/src/zope/app/renderer/vocabulary.py:1.3	Tue Mar  2 09:24:45 2004
+++ Zope3/src/zope/app/renderer/vocabulary.py	Tue Mar  9 07:39:08 2004
@@ -19,20 +19,20 @@
 from zope.proxy import removeAllProxies
 from zope.schema.interfaces import \
      ITokenizedTerm, IVocabulary, IVocabularyTokenized
+from zope.component.interfaces import IFactory
 
 from zope.app import zapi
 from zope.app.browser.form.vocabularywidget import DropdownListWidget
-from zope.app.services.servicenames import Factories
 from zope.app.renderer.interfaces import ISource
 
 class SourceTypeTerm:
 
     implements(ITokenizedTerm)
 
-    def __init__(self, name, info):
+    def __init__(self, name, factory):
         self.token = self.value = name
-        self.title = info.title
-        self.description = info.description
+        self.title = factory.title
+        self.description = factory.description
 
 
 class SourceTypeVocabulary(object):
@@ -40,15 +40,13 @@
     implements(IVocabulary, IVocabularyTokenized)
 
     def __init__(self, context):
-        factories = zapi.getService(context, Factories)
-        self.types = [(name, factories.getFactoryInfo(name)) \
-                      for name, fact in factories.queryFactoriesFor(ISource,
-                                                                    ())]
+        self.types = zapi.getFactoriesFor(None, ISource)
+
     def __contains__(self, value):
-        return value in [name for name, info in self.types]
+        return value in [name for name, fact in self.types]
 
     def __iter__(self):
-        return iter([SourceTypeTerm(name, info) for name, info in self.types])
+        return iter([SourceTypeTerm(name, fact) for name, fact in self.types])
 
     def __len__(self):
         return len(self.types)
@@ -57,9 +55,9 @@
         return None
 
     def getTerm(self, value):
-        for name, info in self.types:
+        for name, fact in self.types:
             if name == value:
-                return SourceTypeTerm(name, info)
+                return SourceTypeTerm(name, fact)
 
         raise KeyError, 'item (%s) not in vocabulary.' %value
 




More information about the Zope3-Checkins mailing list