[CPS-devel] Method Vocabulary in a Generic Multiselect Widget

Anahide Tchertchian at at nuxeo.com
Tue Sep 26 11:37:51 CEST 2006


Jose Jiménez López a écrit :
> Hello,
> 
> When i try to show the result of a Method Vocabulary in a Generic 
> MultiSelect Widget in 'view' mode, it returns an error. The last lines 
> of  the traceback are these:
> 
>  Module Products.PageTemplates.ZRPythonExpr, line 47, in __call__
> __traceback_info__: dir.renderEntryDetailed(id)
>  Module Python expression "dir.renderEntryDetailed(id)", line 1, in 
> <expression>
>  Module Products.CPSDirectory.BaseDirectory, line 562, in 
> renderEntryDetailed
>  Module Products.CPSDirectory.BaseDirectory, line 932, in _renderLayout
>  Module Products.CPSSchemas.Layout, line 391, in renderLayoutStructure
>  Module Products.CPSSchemas.ExtendedWidgets, line 1172, in render
>  Module cgi, line 1039, in escape
> AttributeError: 'list' object has no attribute 'replace'
> 
> My Method Vocabulary returns some like this:
> 
>    [('Member', u'Member'), ('Administrator', u'Administrator')]
> 
> In 'edit' mode the widget shows correctly, but in 'view' mode it crashes.
> 
> I saw the code in ExtendedWidgets.py and i read this "# XXX customize 
> view mode, lots of displays are possible" at line 1167. Does it mean 
> that i have to customize a new mode for my application?
> 
> Thanks
> 

Hi,

I suspect the problem comes from your method vocabulary: it is supposed 
to return a label (e.g. not a list, that would explain the traceback) if 
the parameter named 'key' is not None.

I'm just quoting the MethodVocabulary docstring:

     Define a dynamic vocabulary using a method
     the method have to return a list of tuples like this
     (('foo', "Foo"), ('bar', "Bar"))

     the method should handle a 'key' argument
     if the key is not None then the method must return the value.
     The method should also handle the 'is_i18n' boolean argument
     if it's not False and return msgid corresponsding to the passed
     'key' argument

You may ignore the is_i18n boolean argument as the widget should be able 
to handle it.

Regards,

-- 
Anahide Tchertchian, Nuxeo
Mail: at at nuxeo.com - Tel: +33 (0)1 40 33 71 60
http://www.nuxeo.com - http://www.cps-project.org



This list archive provided by Nuxeo, the leaders of open source ECM. Check out the Nuxeo 5 open source, standards-based ECM project.