From: Hanno S. <ha...@ha...> - 2010-08-01 09:17:07
|
Morning! On Sun, Aug 1, 2010 at 5:35 AM, Martin Aspeli <svn...@pl...> wrote: > Author: optilude > Date: Sun Aug 1 03:35:21 2010 > New Revision: 38408 > > plone.app.uuid/trunk/ (props changed) [...] > Added: plone.app.uuid/trunk/plone/app/uuid/indexer.py > ============================================================================== > --- (empty file) > +++ plone.app.uuid/trunk/plone/app/uuid/indexer.py Sun Aug 1 03:35:21 2010 > @@ -0,0 +1,8 @@ > +from plone.indexer import indexer > + > +from plone.uuid.interfaces import IUUID > +from plone.uuid.interfaces import IUUIDAware > + > +@indexer(IUUIDAware) > +def uuidIndexer(obj): > + return IUUID(obj, None) Shouldn't this raise an AttributeError if no uuid is found? Otherwise we might index lots of values under the key "None". > Added: plone.app.uuid/trunk/plone/app/uuid/utils.py > ============================================================================== > --- (empty file) > +++ plone.app.uuid/trunk/plone/app/uuid/utils.py Sun Aug 1 03:35:21 2010 [...] > +def uuidToCatalogBrain(uuid): > + """Given a UUID, attempt to return a catalog brain. > + """ > + > + site = getSite() > + if site is None: > + return None > + > + catalog = getToolByName(site, 'portal_catalog', None) > + if catalog is None: > + return None > + > + result = catalog(uuid=uuid) > + if len(result) != 1: > + return None > + > + return result[0] I think the "len(result) != 1" case should either raise an exception or at least log an error. If you get multiple objects for an uuid, we have a problem. The Archetypes uid machinery doesn't warn you about this at all and frequently gets you multiple objects per uid thanks to Acquisition or portal_factory fun. Hanno |