On Monday 13 December 2010, Diego Purpo wrote:
> Ciao a tutti.
>
> Sto cercando di eseguire una query al catalog che tra le varie
> condizioni preveda anche una del tipo "attributo not empty", ma ancora
> non ho compreso come si possa realizzare.
>
> Qualcuno ha un suggerimento?!
>
> Grazie

# in __init__.py
from plone.indexer.decorator import indexer
from zope.component import Interface

@indexer(Interface)
def x_non_empty(obj):
    if obj.getX() == "":  #can raise an exception
        return False
    else:
        return True

Si può/deve mettere una interfaccia specifica per evitare che l'indice venga 
chiamato su un oggetto che non ha 'getX'.

Per registrare l'indice mettere in configure.zcml:
      
 <adapter factory='.x_non_empty' name='x_non_empty' />

-- 
Riccardo Lemmi                           Email:   ricca...@reflab.com
Reflab S.r.l. - Plone Design, Development and Consulting
Phone: +39 349 4620820                         http://www.reflab.com

Attachment: signature.asc
Description: This is a digitally signed message part.

_______________________________________________
Plone-IT mailing list
Plone-IT@lists.plone.org
http://lists.plone.org/mailman/listinfo/plone-it
http://www.nabble.com/Plone---Italy-f21728.html

Rispondere a