[Zope3-Users] Selectwidgets (Object is of wrong type)

Maken Seteva crapkonto at gmail.com
Tue Oct 2 16:27:05 EDT 2007


Hi!
I'm having serious problems with getting a selectwidget/ 
dropdownwidget working..
What I want to do is to add a widget for the language field of a  
MessageCatalog.
Btw, a snippet from the interface (in zope.app.i18n.messagecatalog):

  class IMessageCatalog(Interface):
#...
          language = TextLine(
          title=u"Language",
          description=u"The language the catalog translates to.",
          required=True)
#...


I already have an add view working but instead of manually filling in  
'en' for english,
'de' for german, etc. I now have a widget that generates this:

<select>
<option value="en">English</option>
<option value="de">German</option>
<option ...etc


But the thing is, I keep getting "Language: Object is of wrong  
type."  displayed to me
when I click the add button (i.e no system error). Here's the code:

-------------------------------------
  class MessageCatalogAddForm(AddForm):
      form_fields = Fields(IMessageCatalog)
      label = _(u'Add message catalog')
      form_fields['language'].custom_widget = LanguageDropDown

      def create(self, data):
          msgcat = MessageCatalog(data['language'], data['domain'])
          return msgcat

-------------------------------------
class LanguageDropDown(DropdownWidget):

      def __init__(self, field, request):
	# Simple test to begin with, will use locale when i get this working..
          voc = SimpleVocabulary.fromItems([('de','German'),  
('en','English')])
          super(LanguageDropDown, self).__init__(field, voc, request)

      # Display the readable version, German & English instead of de  
& en
      def textForValue(self, term):
          return term.value


-----------------------------------------

I think I'm missing something or doing something wrong in  
LanguageDropdown.__init__

Where does the constraint get checked for this Widget? I keep getting  
"Object is of wrong type" but i can't
find in what function this is generated.

With kindest regards
Seteva
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.zope.org/pipermail/zope3-users/attachments/20071002/fb122b96/attachment.htm


More information about the Zope3-users mailing list