Commit 31202568 authored by Bartek Górny's avatar Bartek Górny

added caching for wiki methods

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@9674 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent f4a35a0e
...@@ -229,12 +229,16 @@ class DMSFile(XMLObject,File): ...@@ -229,12 +229,16 @@ class DMSFile(XMLObject,File):
getWikiSuccessorValueList - the way to find objects is on getWikiSuccessorValueList - the way to find objects is on
implementation level implementation level
''' '''
def cached_getWikiSuccessorValueList():
lst=[] lst=[]
for ref in self.getWikiSuccessorReferenceList(): for ref in self.getWikiSuccessorReferenceList():
res=self.DMS_findDocument(ref) res=self.DMS_findDocument(ref)
if len(res)>0: if len(res)>0:
lst.append(res[0].getObject()) lst.append(res[0].getObject())
return lst return lst
cached_getWikiSuccessorValueList = CachingMethod(cached_getWikiSuccessorValueList,
id='DMSFile_getWikiSuccessorValueList')
return cached_getWikiSuccessorValueList()
security.declareProtected(Permissions.View, 'getWikiPredecessorValueList') security.declareProtected(Permissions.View, 'getWikiPredecessorValueList')
def getWikiPredecessorValueList(self): def getWikiPredecessorValueList(self):
...@@ -243,11 +247,15 @@ class DMSFile(XMLObject,File): ...@@ -243,11 +247,15 @@ class DMSFile(XMLObject,File):
document, and on how a doc must reference me to be my predecessor (reference only, document, and on how a doc must reference me to be my predecessor (reference only,
or with a language, etc or with a language, etc
''' '''
def cached_getWikiPredecessorValueList():
lst=self.DMS_findPredecessors() lst=self.DMS_findPredecessors()
lst=[r.getObject() for r in lst] lst=[r.getObject() for r in lst]
di=dict.fromkeys(lst) # make it unique di=dict.fromkeys(lst) # make it unique
ref=self.getReference() ref=self.getReference()
return [o for o in di.keys() if o.getReference()!=ref] # every object has its own reference in SearchableText return [o for o in di.keys() if o.getReference()!=ref] # every object has its own reference in SearchableText
cached_getWikiPredecessorValueList=CachingMethod(cached_getWikiPredecessorValueList,
id='DMSFile_getWikiPredecessorValueList')
return cached_getWikiPredecessorValueList()
security.declareProtected(Permissions.View,'getContributors') security.declareProtected(Permissions.View,'getContributors')
def getContributorList(self): def getContributorList(self):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment