Commit 64de5703 authored by Jérome Perrin's avatar Jérome Perrin

Use getattr instead of hasattr for uid buffer and security uid dict.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@6938 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent a339b01c
...@@ -565,7 +565,7 @@ class Catalog(Folder, Persistent, Acquisition.Implicit, ExtensionClass.Base): ...@@ -565,7 +565,7 @@ class Catalog(Folder, Persistent, Acquisition.Implicit, ExtensionClass.Base):
self.security_uid_index = 0 self.security_uid_index = 0
security.declarePrivate('getSecurityUid') security.declarePrivate('getSecurityUid')
def getSecurityUid(self, object): def getSecurityUid(self, wrapped_object):
""" """
Cache a uid for each security permission Cache a uid for each security permission
...@@ -573,13 +573,13 @@ class Catalog(Folder, Persistent, Acquisition.Implicit, ExtensionClass.Base): ...@@ -573,13 +573,13 @@ class Catalog(Folder, Persistent, Acquisition.Implicit, ExtensionClass.Base):
and to assign security only to root document and to assign security only to root document
""" """
# Get security information # Get security information
allowed_roles_and_users = object.allowedRolesAndUsers() allowed_roles_and_users = wrapped_object.allowedRolesAndUsers()
# Sort it # Sort it
allowed_roles_and_users = list(allowed_roles_and_users) allowed_roles_and_users = list(allowed_roles_and_users)
allowed_roles_and_users.sort() allowed_roles_and_users.sort()
allowed_roles_and_users = tuple(allowed_roles_and_users) allowed_roles_and_users = tuple(allowed_roles_and_users)
# Make sure no diplicates # Make sure no duplicates
if not hasattr(aq_base(self), 'security_uid_dict'): if getattr(aq_base(self), 'security_uid_dict', None) is None:
self._clearSecurityCache() self._clearSecurityCache()
if self.security_uid_dict.has_key(allowed_roles_and_users): if self.security_uid_dict.has_key(allowed_roles_and_users):
return (self.security_uid_dict[allowed_roles_and_users], None) return (self.security_uid_dict[allowed_roles_and_users], None)
...@@ -787,7 +787,7 @@ class Catalog(Folder, Persistent, Acquisition.Implicit, ExtensionClass.Base): ...@@ -787,7 +787,7 @@ class Catalog(Folder, Persistent, Acquisition.Implicit, ExtensionClass.Base):
if klass._local_clear_reserved_time != self._last_clear_reserved_time: if klass._local_clear_reserved_time != self._last_clear_reserved_time:
self._v_uid_buffer = UidBuffer() self._v_uid_buffer = UidBuffer()
klass._local_clear_reserved_time = self._last_clear_reserved_time klass._local_clear_reserved_time = self._last_clear_reserved_time
elif not hasattr(self, '_v_uid_buffer'): elif getattr(self, '_v_uid_buffer', None) is None:
self._v_uid_buffer = UidBuffer() self._v_uid_buffer = UidBuffer()
if len(self._v_uid_buffer) == 0: if len(self._v_uid_buffer) == 0:
method_id = self.sql_catalog_produce_reserved method_id = self.sql_catalog_produce_reserved
...@@ -1032,7 +1032,7 @@ class Catalog(Folder, Persistent, Acquisition.Implicit, ExtensionClass.Base): ...@@ -1032,7 +1032,7 @@ class Catalog(Folder, Persistent, Acquisition.Implicit, ExtensionClass.Base):
klass = self.__class__ klass = self.__class__
try: try:
klass._reserved_uid_lock.acquire() klass._reserved_uid_lock.acquire()
if hasattr(self, '_v_uid_buffer'): if getattr(self, '_v_uid_buffer', None) is not None:
# This is the case where: # This is the case where:
# 1. The object got an uid. # 1. The object got an uid.
# 2. The catalog was cleared. # 2. The catalog was cleared.
......
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