[Plone-IT] MasterSelectWidget

Natale Tarantino ntarantino a regione.sicilia.it
Mar 12 Nov 2013 12:45:36 UTC



Il 12/11/2013 13:36, Luca Fabbri ha scritto:
> 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"?
>
>
>
master dovrebbe essere il parametro passato da category


-- 
-------------- parte successiva --------------
Un allegato HTML è stato rimosso...
URL: <http://lists.plone.org/pipermail/plone-plone-it/attachments/20131112/5b78ffa5/attachment-0001.html>
-------------- parte successiva --------------
Un allegato non testuale è stato rimosso....
Nome:        tarantino.JPG
Tipo:        image/jpeg
Dimensione:  21729 bytes
Descrizione: non disponibile
URL:         <http://lists.plone.org/pipermail/plone-plone-it/attachments/20131112/5b78ffa5/attachment-0001.jpe>


Maggiori informazioni sulla lista Plone-IT