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

2007-10-02 Thread Leonardo Rochael

You are probably experiencing a ValidationError in the .validate() method of
your "language" field. This is probably because TextLine expect the values
to be unicode whereas the vocabulary in your widget has (8-bit) string
values ("voc = SimpleVocabulary.fromItems([('de','German'), 
('en','English')])".


Maken Seteva wrote:
> 
> 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:
> 
> 
> English
> German
>  
> 
> 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.
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Selectwidgets-%28Object-is-of-wrong-type%29-tf4557862.html#a13011336
Sent from the Zope3 - users mailing list archive at Nabble.com.

___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


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

2007-10-02 Thread Maken Seteva

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:


English
German
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___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


[Zope3-Users] Re: Choice Field with MultiCheckBoxWidget?

2007-10-02 Thread Christian Klinger

Christian Klinger schrieb:

Hi,

i try to have a form with an ChoiceField rendered as a MultiCheckBoxWidget.

interfaces.py
-
berechtigung = schema.Choice(title=_(u'Berechtigung'),
   description=_(u'Berechtiung'),
   missing_value=None,

#value_type=schema.Choice(vocabulary="VocabularyBerechtigungen"))
   vocabulary="VocabularyBerechtigungen")


browser.py:
--
form_fields['berechtigung'].custom_widget = MultiCheckBox??


Where can i find a MulitCheckBoxWidget?
Is this the right way to do this?

Christian


I got it i have to use a schema.List(...)

Thx Christian

___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


[Zope3-Users] Choice Field with MultiCheckBoxWidget?

2007-10-02 Thread Christian Klinger

Hi,

i try to have a form with an ChoiceField rendered as a MultiCheckBoxWidget.

interfaces.py
-
berechtigung = schema.Choice(title=_(u'Berechtigung'),
   description=_(u'Berechtiung'),
   missing_value=None,

#value_type=schema.Choice(vocabulary="VocabularyBerechtigungen"))
   vocabulary="VocabularyBerechtigungen")


browser.py:
--
form_fields['berechtigung'].custom_widget = MultiCheckBox??


Where can i find a MulitCheckBoxWidget?
Is this the right way to do this?

Christian

___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users