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(
         description=u"The language the catalog translates to.",

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:

<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
Zope3-users mailing list

Reply via email to