[Zope-dev] z3c.formwidget.query - incorrect interface implementation?

Martin Aspeli optilude at gmx.net
Sun Aug 24 17:18:05 EDT 2008


Malthe Borch wrote:
> Martin Aspeli wrote:
>> I'm trying to build a widget that allows for auto-complete of items in a 
>> vocabulary, but also allows additional (string) values to be added. To 
>> understand how that works, I am digging into z3c.formwidget.query, and 
>> it looks to me like it's making incorrect assumptions about its own 
>> interfaces.
> 
> This can very well be; the defense would be that the entire vocabulary 
> code is full of odd interfaces that don't really form a complete story.

For what it's worth, I agree. :-)

>> If I'm not reading this wrong, it seems to me that z3c.formwidget.query 
>> is using getTermByValue() (which I can't find anywhere else) instead of 
>> getTermByToken() as defined by IVocabularyTokenized.
> 
> I don't remember the details, but the implementation may be incorrect 
> although functional. Certainly, it's made to good use by 
> ``plone.app.z3cform`` and a number of other modules.
> 
> You're more than welcome to improve or devise an alternative implementation.

Have you ever tested it with a source other than the one in 
queryselect's example code and the one in plone.app.z3cform.queryselect? 
Those are the only places I can see getTermByValue().

The fix would probably be to make sure it uses tokens everywhere and 
implement getTermByToken.

Martin

-- 
Author of `Professional Plone Development`, a book for developers who
want to work with Plone. See http://martinaspeli.net/plone-book



More information about the Zope-Dev mailing list