[Zope3-checkins] CVS: Zope3/src/zope/app/renderer - configure.zcml:1.11 vocabulary.py:1.10

Gary Poster gary at zope.com
Thu May 6 12:14:19 EDT 2004


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

Modified Files:
	configure.zcml vocabulary.py 
Log Message:
Convert the field collection behavior as described in 
http://mail.zope.org/pipermail/zope3-dev/2004-May/010797.html

The Sequence field is removed.  As I spoke with Stephan, it may be acceptable to add the Sequence field back in if it actually means something.  Sequence did mean it was iterable but container access API was not described.  It should be described.  IPythonSequence might describe this API.  A Sequence widget should require specification of the factory.

Set now specifies a sets.Set.

IChoiceSequence was removed.




=== Zope3/src/zope/app/renderer/configure.zcml 1.10 => 1.11 ===
--- Zope3/src/zope/app/renderer/configure.zcml:1.10	Thu Apr 29 08:19:39 2004
+++ Zope3/src/zope/app/renderer/configure.zcml	Thu May  6 12:13:42 2004
@@ -8,27 +8,6 @@
       name="SourceTypes"
       factory=".vocabulary.SourceTypeVocabulary" />
 
-  <content class=".vocabulary.SourceTypeVocabulary">
-    <allow interface="zope.schema.interfaces.IVocabulary"/>
-    <allow interface="zope.schema.interfaces.IVocabularyTokenized"/>
-  </content>
-
-  <content class=".vocabulary.SourceTypeTerm">
-    <allow
-        interface="zope.schema.interfaces.ITokenizedTerm"
-        attributes="title"/>
-  </content>
-
-  <view
-      type="zope.publisher.interfaces.browser.IBrowserRequest"
-      for="zope.schema.interfaces.IChoiceSequence
-           .vocabulary.ISourceTypeVocabulary"
-      provides="zope.app.form.interfaces.IInputWidget"
-      factory=".vocabulary.SourceTypeEditWidget"
-      permission="zope.Public"
-      />
-  
-
   <!-- Plain Text Support -->
 
   <factory
@@ -70,16 +49,5 @@
       for=".rest.IReStructuredTextSource"
       class=".rest.ReStructuredTextToHTMLRenderer"
       permission="zope.Public" />
-
-  <!-- Special widget for Choice fields with ISourceType vocabularies -->
-
-  <view
-      type="zope.publisher.interfaces.browser.IBrowserRequest"
-      for="zope.schema.interfaces.IChoice
-           .vocabulary.ISourceTypeVocabulary"
-      provides="zope.app.form.interfaces.IInputWidget"
-      factory=".vocabulary.SourceTypeEditWidget"
-      permission="zope.Public"
-      />
 
 </configure>


=== Zope3/src/zope/app/renderer/vocabulary.py 1.9 => 1.10 ===
--- Zope3/src/zope/app/renderer/vocabulary.py:1.9	Thu Apr 29 08:19:39 2004
+++ Zope3/src/zope/app/renderer/vocabulary.py	Thu May  6 12:13:42 2004
@@ -15,61 +15,13 @@
 
 $Id$
 """
-from zope.interface import implements
-from zope.proxy import removeAllProxies
-from zope.schema.interfaces import \
-     ITokenizedTerm, IVocabulary, IVocabularyTokenized
-from zope.schema.vocabulary import getVocabularyRegistry
-from zope.component.interfaces import IFactory
+from zope.schema.vocabulary import SimpleVocabulary, SimpleTerm
 
 from zope.app import zapi
 from zope.app.form.browser import DropdownWidget
 from zope.app.renderer.interfaces import ISource
 
-class ISourceTypeVocabulary(IVocabulary, IVocabularyTokenized):
-    """Marker interface, so we can register a special widget for it."""
-
-class SourceTypeTerm:
-
-    implements(ITokenizedTerm)
-
-    def __init__(self, name, factory):
-        self.token = self.value = name
-        self.title = factory.title
-        self.description = factory.description
-
-
-class SourceTypeVocabulary(object):
-
-    implements(ISourceTypeVocabulary)
-
-    def __init__(self, context):
-        self.types = list(zapi.getFactoriesFor(None, ISource))
-
-    def __contains__(self, value):
-        return value in [name for name, fact in self.types]
-
-    def __iter__(self):
-        return iter([SourceTypeTerm(name, fact) for name, fact in self.types])
-
-    def __len__(self):
-        return len(self.types)
-
-    def getQuery(self):
-        return None
-
-    def getTerm(self, value):
-        for name, fact in self.types:
-            if name == value:
-                return SourceTypeTerm(name, fact)
-
-        raise KeyError, 'item (%s) not in vocabulary.' %value
-
-    def getTermByToken(self, token):
-        return self.getTerm(token)
-
-
-class SourceTypeEditWidget(DropdownWidget):
-
-    def textForValue(self, term):
-        return term.title
+def SourceTypeVocabulary(context):
+    return SimpleVocabulary(
+        [SimpleTerm(name, title=factory.title) for name, factory in 
+         zapi.getFactoriesFor(None, ISource)])




More information about the Zope3-Checkins mailing list