Commit c26b0262 authored by Jean-Paul Smets's avatar Jean-Paul Smets

Use of BTree


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@568 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent f5de7228
...@@ -32,7 +32,7 @@ from AccessControl import ClassSecurityInfo ...@@ -32,7 +32,7 @@ from AccessControl import ClassSecurityInfo
from Products.CMFCore import CMFCorePermissions from Products.CMFCore import CMFCorePermissions
from Products.ERP5Type.Base import Base from Products.ERP5Type.Base import Base
from Products.ERP5Type import PropertySheet from Products.ERP5Type import PropertySheet
from BTrees.OOBTree import OOTreeSet from BTrees.IOBTree import IOBTree
from zLOG import LOG from zLOG import LOG
...@@ -73,17 +73,32 @@ class ActiveProcess(Base): ...@@ -73,17 +73,32 @@ class ActiveProcess(Base):
# Declarative properties # Declarative properties
property_sheets = ( PropertySheet.Base property_sheets = ( PropertySheet.Base
, PropertySheet.SimpleItem ) , PropertySheet.SimpleItem
, PropertySheet.Folder )
# Declarative constructors # Declarative constructors
constructors = (manage_addActiveProcessForm, addActiveProcess) constructors = (manage_addActiveProcessForm, addActiveProcess)
# Base methods # Base methods
def _generateNewId(self):
"""
Generate a new result id for internal storage
"""
try:
my_id = int(self.getLastId())
except:
my_id = 1
while self.result_list.has_key(my_id):
my_id = my_id + 1
self._setLastId(str(my_id)) # Make sure no reindexing happens
return my_id
security.declareProtected(CMFCorePermissions.ManagePortal, 'postResult') security.declareProtected(CMFCorePermissions.ManagePortal, 'postResult')
def postResult(self, result): def postResult(self, result):
if not hasattr(self, 'result_list'): if not hasattr(self, 'result_list'):
self.result_list = OOTreeSet() self.result_list = IOBTree()
self.result_list.insert(result) self.result_list[self._generateNewId()] = result
security.declareProtected(CMFCorePermissions.ManagePortal, 'getResultList') security.declareProtected(CMFCorePermissions.ManagePortal, 'getResultList')
def getResultList(self, **kw): def getResultList(self, **kw):
...@@ -91,8 +106,9 @@ class ActiveProcess(Base): ...@@ -91,8 +106,9 @@ class ActiveProcess(Base):
Returns the list of results Returns the list of results
""" """
if not hasattr(self, 'result_list'): if not hasattr(self, 'result_list'):
self.result_list = OOTreeSet() self.result_list = IOBTree()
return self.result_list # Improve this to include sort order XXX
return self.result_list.values()
# security.declareProtected(CMFCorePermissions.ManagePortal, 'getErrorListText') # security.declareProtected(CMFCorePermissions.ManagePortal, 'getErrorListText')
# def getResultListText(self): # def getResultListText(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