[Zope3-checkins] SVN: Zope3/trunk/src/zope/app/form/browser/itemswidgets.py Fix bug.

Stephan Richter srichter at cosmos.phy.tufts.edu
Thu Oct 14 09:20:29 EDT 2004


Log message for revision 28176:
  Fix bug.
  

Changed:
  U   Zope3/trunk/src/zope/app/form/browser/itemswidgets.py

-=-
Modified: Zope3/trunk/src/zope/app/form/browser/itemswidgets.py
===================================================================
--- Zope3/trunk/src/zope/app/form/browser/itemswidgets.py	2004-10-14 12:46:49 UTC (rev 28175)
+++ Zope3/trunk/src/zope/app/form/browser/itemswidgets.py	2004-10-14 13:20:28 UTC (rev 28176)
@@ -531,13 +531,20 @@
 
     def choices(self):
         """Return a set of tuples (text, value) that are available."""
-        selected_values = self.context.get(self.context.context)
+        # Not all content object must necessarily support the attributes
+        if hasattr(self.context.context, self.context.__name__):
+            selected_values = self.context.get(self.context.context)
+        else:
+            selected_values = []
         return [{'text': self.textForValue(term), 'value': term.token}
                 for term in self.vocabulary
                 if term.value not in selected_values]
         
     def selected(self):
         """Return a list of tuples (text, value) that are selected."""
+        # Not all content object must necessarily support the attributes
+        if not hasattr(self.context.context, self.context.__name__):
+            return []
         terms = [self.vocabulary.getTerm(value)
                  for value in self.context.get(self.context.context)]
         return [{'text': self.textForValue(term), 'value': term.token}



More information about the Zope3-Checkins mailing list