[Zope3-checkins] CVS: Zope3/src/zope/app/browser/component - interfacewidget.py:1.22
Jim Fulton
jim@zope.com
Sat, 25 Jan 2003 08:10:28 -0500
Update of /cvs-repository/Zope3/src/zope/app/browser/component
In directory cvs.zope.org:/tmp/cvs-serv14015
Modified Files:
interfacewidget.py
Log Message:
Added code to get the interface widget to only show interfaces that
satisfy the field constraint.
Added notation that multi-interface widgets should be used with
multi-interface fields, which we don't have yet.
Changed some string literal formatting to avoid confusing emacs Python
mode.
=== Zope3/src/zope/app/browser/component/interfacewidget.py 1.21 => 1.22 ===
--- Zope3/src/zope/app/browser/component/interfacewidget.py:1.21 Mon Jan 20 09:36:12 2003
+++ Zope3/src/zope/app/browser/component/interfacewidget.py Sat Jan 25 08:09:56 2003
@@ -77,7 +77,14 @@
include_none = base is None
if base == Interface:
base = None
+
interfaces = list(service.searchInterface(search_string, base=base))
+
+ if field.constraint is not None:
+ interfaces = [i
+ for i in interfaces
+ if field.constraint(i)
+ ]
interfaces.sort()
interfaces = map(interfaceToName, interfaces)
# Only include None if there is no search string, and include_none
@@ -129,6 +136,8 @@
'See IBrowserWidget'
raise NotImplementedError
+
+# XXX Note that MultiInterface widgets should be for multi-interface fields
class MultiInterfaceWidget(Widget, BrowserView):