From 3fc5bc8418ab2ab4391a00bc6a5c6f44611de95d Mon Sep 17 00:00:00 2001 From: Gaetan Delannay Date: Tue, 22 Feb 2011 14:16:42 +0100 Subject: [PATCH] appy.gen: bugfix while indexing empty string values: bugfix while accessing object from a query without security enabled. --- gen/__init__.py | 4 ++++ gen/plone25/wrappers/__init__.py | 4 +++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/gen/__init__.py b/gen/__init__.py index 6830d4c..0768bb5 100644 --- a/gen/__init__.py +++ b/gen/__init__.py @@ -1176,6 +1176,7 @@ class String(Type): return res emptyStringTuple = ('',) + emptyValuesCatalogIgnored = (None, '') def getIndexValue(self, obj, forSearch=False): '''For indexing purposes, we return only strings, not unicodes.''' res = Type.getIndexValue(self, obj, forSearch) @@ -1185,6 +1186,9 @@ class String(Type): # portal_catalog keeps the previous value! If I give him a tuple # containing an empty string, it is ok. if isinstance(res, tuple) and not res: res = self.emptyStringTuple + # Ugly portal_catalog: if value is an empty string or None, it keeps + # the previous index value! + if res in self.emptyValuesCatalogIgnored: res = ' ' return res def getPossibleValues(self,obj,withTranslations=False,withBlankValue=False): diff --git a/gen/plone25/wrappers/__init__.py b/gen/plone25/wrappers/__init__.py index 4ecde6f..ef08767 100644 --- a/gen/plone25/wrappers/__init__.py +++ b/gen/plone25/wrappers/__init__.py @@ -362,7 +362,9 @@ class AbstractWrapper: for brain in self.tool.o.executeQuery(contentType, search=search, \ brainsOnly=True, maxResults=maxResults, noSecurity=noSecurity): # Get the Appy object from the brain - obj = brain.getObject().appy() + if noSecurity: method = '_unrestrictedGetObject' + else: method = 'getObject' + exec 'obj = brain.%s().appy()' % method exec expression return ctx