Commit c6d2392e authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki

use OOBTree instead of PersistentMapping for PasswordTool's dict.

to avoid conflicts and to improve disk space efficiency.
parent 6b83d2b1
...@@ -40,6 +40,7 @@ from hashlib import md5 ...@@ -40,6 +40,7 @@ from hashlib import md5
from DateTime import DateTime from DateTime import DateTime
from Products.ERP5Type.Message import translateString from Products.ERP5Type.Message import translateString
from Products.ERP5Type.Globals import PersistentMapping from Products.ERP5Type.Globals import PersistentMapping
from BTrees.OOBTree import OOBTree
from urllib import urlencode from urllib import urlencode
class PasswordTool(BaseTool): class PasswordTool(BaseTool):
...@@ -60,12 +61,11 @@ class PasswordTool(BaseTool): ...@@ -60,12 +61,11 @@ class PasswordTool(BaseTool):
_expiration_day = 1 _expiration_day = 1
_password_request_dict = {}
def __init__(self, id=None): def __init__(self, id=None):
if id is None: if id is None:
id = self.__class__.id id = self.__class__.id
self._password_request_dict = PersistentMapping() self._password_request_dict = OOBTree()
# XXX no call to BaseTool.__init__ ? # XXX no call to BaseTool.__init__ ?
# BaseTool.__init__(self, id) # BaseTool.__init__(self, id)
...@@ -77,13 +77,10 @@ class PasswordTool(BaseTool): ...@@ -77,13 +77,10 @@ class PasswordTool(BaseTool):
# generate a random string # generate a random string
key = self._generateUUID() key = self._generateUUID()
# XXX before r26093, _password_request_dict was initialized by an OOBTree and if isinstance(self._password_request_dict, PersistentMapping):
# replaced by a dict on each request, so if it's data structure is not up LOG('ERP5.PasswordTool', INFO, 'Migrating password_request_dict to'
# to date, we update it if needed ' OOBTree')
if not isinstance(self._password_request_dict, PersistentMapping): self._password_request_dict = OOBTree(self._password_request_dict)
LOG('ERP5.PasswordTool', INFO, 'Updating password_request_dict to'
' PersistentMapping')
self._password_request_dict = PersistentMapping()
# register request # register request
self._password_request_dict[key] = (user_login, expiration_date) self._password_request_dict[key] = (user_login, expiration_date)
......
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