<HTML><BODY style="word-wrap: break-word; -khtml-nbsp-mode: space; -khtml-line-break: after-white-space; ">Hi!<DIV>I'm having serious problems with getting a selectwidget/dropdownwidget working..</DIV><DIV>What I want to do is to add a widget for the language field of a MessageCatalog.</DIV><DIV>Btw, a snippet from the interface (in zope.app.i18n.messagecatalog):</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV> class IMessageCatalog(Interface):</DIV><DIV>#...</DIV><DIV>         language = TextLine(</DIV><DIV>         title=u"Language",</DIV><DIV>         description=u"The language the catalog translates to.",</DIV><DIV>         required=True)</DIV><DIV>#...</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>I already have an add view working but instead of manually filling in 'en' for english, </DIV><DIV>'de' for german, etc. I now have a widget that generates this:</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>&lt;select&gt;</DIV><DIV>&lt;option value="en"&gt;English&lt;/option&gt;</DIV><DIV>&lt;option value="de"&gt;German&lt;/option&gt;</DIV><DIV>&lt;option ...etc</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>But the thing is, I keep getting "<FONT class="Apple-style-span" size="4"><SPAN class="Apple-style-span" style="font-size: 14px;">Language: Object is of wrong type." </SPAN></FONT> displayed to me</DIV><DIV>when I click the add button (i.e no system error). Here's the code:</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>-------------------------------------</DIV><DIV> class MessageCatalogAddForm(AddForm):</DIV><DIV>     form_fields = Fields(IMessageCatalog)</DIV><DIV>     label = _(u'Add message catalog')</DIV><DIV>     form_fields['language'].custom_widget = LanguageDropDown</DIV><DIV>     </DIV><DIV>     def create(self, data):</DIV><DIV>         msgcat = MessageCatalog(data['language'], data['domain'])</DIV><DIV>         return msgcat</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>-------------------------------------</DIV><DIV> class LanguageDropDown(DropdownWidget):</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>     def __init__(self, field, request):</DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN># Simple test to begin with, will use locale when i get this working..</DIV><DIV>         voc = SimpleVocabulary.fromItems([('de','German'), ('en','English')])</DIV><DIV>         super(LanguageDropDown, self).__init__(field, voc, request)</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>     # Display the readable version, German &amp; English instead of de &amp; en</DIV><DIV>     def textForValue(self, term):</DIV><DIV>         return term.value</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>-----------------------------------------</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>I think I'm missing something or doing something wrong in LanguageDropdown.__init__</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>Where does the constraint get checked for this Widget? I keep getting "Object is of wrong type" but i can't </DIV><DIV>find in what function this is generated.</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>With kindest regards</DIV><DIV>Seteva</DIV></BODY></HTML>