[gen] Added field.getCatalogValue allowing, for indexed values, to get the value as indexed in the Zope catalog. [gen] field Computed: added param formatMethod allowing to define the way to format the computed value (ie: the formatted value can then be different from the 'raw' value: this can be interesting if the raw value must be indexed.
This commit is contained in:
parent
ecb970e519
commit
e72f53c0d9
3 changed files with 31 additions and 6 deletions
|
@ -22,6 +22,7 @@ from appy.gen import utils as gutils
|
|||
from appy.px import Px
|
||||
from appy.shared import utils as sutils
|
||||
from group import Group
|
||||
from search import Search
|
||||
from page import Page
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
|
@ -588,6 +589,18 @@ class Field:
|
|||
res = str(res)
|
||||
return res
|
||||
|
||||
def getCatalogValue(self, obj, usage='search'):
|
||||
'''This method returns the index value that is currently stored in the
|
||||
catalog for this field on p_obj.'''
|
||||
if not self.indexed:
|
||||
raise Exception('Field %s: cannot retrieve catalog version of ' \
|
||||
'unindexed field.' % self.name)
|
||||
tool = obj.getTool()
|
||||
indexName = Search.getIndexName(self.name, usage=usage)
|
||||
catalogBrain = tool.getObject(obj.id, brain=True)
|
||||
index = tool.getApp().catalog.Indexes[indexName]
|
||||
return index.getEntryForObject(catalogBrain.getRID())
|
||||
|
||||
def valueIsInRequest(self, obj, request, name):
|
||||
'''Is there a value corresponding to this field in the request? p_name
|
||||
can be different from self.name (ie, if it is a field within another
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue