Commit 8ef67021 authored by Jérome Perrin's avatar Jérome Perrin

ZSQLCatalog: use _getProperty to skip security checks

During indexation we don't apply security checks, so this should be a
little bit faster.

With this change _getProperty becomes a more "official" API, so some
small changes had to be made to classes which do not inherits from
Products.ERP5Type.Base.Base, so that they also implements _getProperty:
 - for ERP5Site we simply use getProperty
 - for the test class from testERP5Catalog, the change is a bit more
important, because this class never defined getProperty, so during that
test we were just acquiering a getProperty from portal.
parent 992c5438
......@@ -565,6 +565,12 @@ class ERP5Site(FolderMixIn, CMFSite, CacheCookieMixin):
return self._v_version_priority_name_list
# Make sure ERP5Site follow same API as Products.ERP5Type.Base
# _getProperty is missing, but since there are no protected properties
# on an ERP5 Site, we can just use getProperty instead.
_getProperty = CMFSite.getProperty
security.declareProtected(Permissions.AccessContentsInformation, 'getUid')
def getUid(self):
"""
......
......@@ -33,6 +33,7 @@ import unittest
import httplib
from AccessControl import getSecurityManager
from AccessControl.SecurityManagement import newSecurityManager
from Acquisition import aq_base
from DateTime import DateTime
from _mysql_exceptions import ProgrammingError
from OFS.ObjectManager import ObjectManager
......@@ -44,6 +45,8 @@ from Testing import ZopeTestCase
from zLOG import LOG
class IndexableDocument(ObjectManager):
# This tests uses a simple ObjectManager, but ERP5Catalog only
# support classes inherting from ERP5Type.Base.
# this property is required for dummy providesIMovement
__allow_access_to_unprotected_subobjects__ = 1
......@@ -66,6 +69,11 @@ class IndexableDocument(ObjectManager):
return lambda: 0
raise AttributeError, name
def getProperty(self, prop, default=None):
return getattr(aq_base(self), prop, default)
_getProperty = getProperty
def getPath(self):
return self._path
......
......@@ -1395,7 +1395,7 @@ class Catalog(Folder,
# objects but we could also use over multiple transactions
# if this can improve performance significantly
# ZZZ - we could find a way to compute this once only
cache_key = tuple(object.getProperty(key) for key
cache_key = tuple(object._getProperty(key) for key
in expression_cache_key_list)
try:
if expression_result_cache[cache_key]:
......
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