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
''' '''
lst=[] def cached_getWikiSuccessorValueList():
for ref in self.getWikiSuccessorReferenceList(): lst=[]
res=self.DMS_findDocument(ref) for ref in self.getWikiSuccessorReferenceList():
if len(res)>0: res=self.DMS_findDocument(ref)
lst.append(res[0].getObject()) if len(res)>0:
return lst lst.append(res[0].getObject())
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
''' '''
lst=self.DMS_findPredecessors() def cached_getWikiPredecessorValueList():
lst=[r.getObject() for r in lst] lst=self.DMS_findPredecessors()
di=dict.fromkeys(lst) # make it unique lst=[r.getObject() for r in lst]
ref=self.getReference() di=dict.fromkeys(lst) # make it unique
return [o for o in di.keys() if o.getReference()!=ref] # every object has its own reference in SearchableText ref=self.getReference()
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