Re: Method Vocabulary in a Generic Multiselect Widget

Anahide Tchertchian <[email protected]>
Newsgroups gmane.comp.web.zope.cps.devel
Message-ID <[email protected]>
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: [email protected] - Tel: +33 (0)1 40 33 71 60
http://www.nuxeo.com - http://www.cps-project.org
_______________________________________________
cps-devel mailing list
http://lists.nuxeo.com/mailman/listinfo/cps-devel
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.