[Plone-IT] MasterSelectWidget

Luca Fabbri keul a redturtle.it
Mar 12 Nov 2013 12:36:09 UTC


On Tue, Nov 12, 2013 at 1:03 PM, Natale Tarantino
<ntarantino a regione.sicilia.it> wrote:
>
> Ciao,
> sto scrivendo un  prodotto, basato su Archetypes, e vorrei usare la MasterSelectWidget con Plone 4.2.4
> Premesso che la demo della widget funziona posto il codice:
>
> slave_fields2 = (
>     #Controls the vocabulary of subcategory
>     {'name': 'subcategory',
>      'action': 'vocabulary',
>      'vocab_method':'subcategoryVocab',
>      'control_param':'master',
>     },
> )
>
> ATTicketSchema = folder.ATFolderSchema.copy() + atapi.Schema((
> .....
>     atapi.StringField('category',
>         searchable=0,
>         required=0,
>         vocabulary='categoryVocab',
>         widget=MasterSelectWidget(
>             slave_fields=slave_fields2,
>             description="Master",
>         ),
>     ),
>
>     atapi.StringField('subcategory',
>         searchable=0,
>         required=0,
>         default='',
>         vocabulary='subcategoryVocab',
>         widget=atapi.SelectionWidget(
>             format='select',
>             label=_(u'subcategory_label', default=u'Sub Category'),
>             description=_(u'subcategory_help', default=u"Select helpdesk request sub type"),
>             ),
>     ),
> .......
>     security.declarePublic('categoryVocab')
>     def categoryVocab(self):
>         """ """
>         categories = DisplayList()
>         categories.add('', _(u'-- not specified --'))
>         for category in self.aq_parent.getCategory_list():
>             categories.add(category, category)
>         return categories
>
>     security.declarePublic('subcategoryVocab')
>     def subcategoryVocab(self, master):
>         subcategories = DisplayList()
>         subcategories.add('', _(u'-- not specified --'))
>         for subcategory in self.aq_parent.getSubcategory_list():
>             #if subcategory[0] == master[0]:
>                 subcategories.add(subcategory, subcategory)
>         return subcategories
>
> ma sembra non trovare il valore di master
>
> Error
> Module zope.pagetemplate.pagetemplate, line 113, in pt_render
> Warning: Macro expansion failed
> Warning: <type 'exceptions.KeyError'>: 'macro'
> ......
> URL: file:/usr/local/Plone/buildout-cache/eggs/Products.Archetypes-1.8.6-py2.7.egg/Products/Archetypes/skins/archetypes/widgets/selection.pt
> Line 36, Column 12
> Expression: <PythonExpr field.Vocabulary(context)>
> Names:
> .......
>
>   Module Products.Archetypes.utils, line 125, in mapply
>
> TypeError: subcategoryVocab() takes exactly 2 arguments (1 given)
> .......
>
> Sbaglio o dovrei vedere con firebug una chiamata a masterselect.js?
>
> Qualche idea?
>

Sembra sbagliata la definizione di subcategoryVocab. Cos' "master"?



-- 
Saluti/Regards

Luca Fabbri - RedTurtle Technology
E-mail: luca.fabbri a redturtle.it
Web Site: http://www.redturtle.it/
Phone: +39 0532 1915958
Fax: +39 0532 287070


Maggiori informazioni sulla lista Plone-IT