appy.gen: bugfix while indexing empty string values: bugfix while accessing object from a query without security enabled.

This commit is contained in:
Gaetan Delannay 2011-02-22 14:16:42 +01:00
parent 312b1f4cef
commit 3fc5bc8418
2 changed files with 7 additions and 1 deletions

View file

@ -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):

View file

@ -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