Commit e2f0c11d authored by Ayush Tiwari's avatar Ayush Tiwari

erp5_catalog: Solve name conflict between isIndexable property for ERP5Site and ERP5 Catalog

Earlier, In ERP5Site, we use property 'isIndexable' to have control over indexing and unindexing.
This was usefull specially in case of bootstrap. To have this control, we had a function
`isIndexable` in SQLCatalog which we used to switch for enabling-disabling indexation. (769f9fb2)

Now, we do have ERP5 Catalog, which itself is an ERP5 Object, hence it has an accessor `isIndexable`
of itself which we plan to disable for now(as we don't want circular dependency while indexing
catalog in itself). But as we did have a function `isIndexable` in SQLCatalog which had control
over the indexing, we needed to rename this property for ERP5Site.

Hence, now we use property 'isIndexingRequired' for ERP5Site and use to have overall control
over indexing process.

Please note, we do not intend to change the same property name for any other object. Its just
for ERP5Site.
parent dcb2a427
...@@ -5332,7 +5332,7 @@ Business Template is a set of definitions, such as skins, portal types and categ ...@@ -5332,7 +5332,7 @@ Business Template is a set of definitions, such as skins, portal types and categ
if update_catalog: if update_catalog:
catalog = _getCatalogValue(self) catalog = _getCatalogValue(self)
if (catalog is None) or (not site.isIndexable): if (catalog is None) or (not site.isIndexingRequired):
LOG('Business Template', 0, 'no SQL Catalog available') LOG('Business Template', 0, 'no SQL Catalog available')
update_catalog = 0 update_catalog = 0
else: else:
......
...@@ -235,7 +235,7 @@ class ERP5Site(FolderMixIn, CMFSite, CacheCookieMixin): ...@@ -235,7 +235,7 @@ class ERP5Site(FolderMixIn, CMFSite, CacheCookieMixin):
last_id = 0 last_id = 0
icon = 'portal.gif' icon = 'portal.gif'
# Default value, prevents error during upgrade # Default value, prevents error during upgrade
isIndexable = ConstantGetter('isIndexable', value=True) isIndexingRequired = ConstantGetter('isIndexingRequired', value=True)
_properties = ( _properties = (
{ 'id':'title', { 'id':'title',
...@@ -1967,7 +1967,7 @@ class ERP5Generator(PortalGenerator): ...@@ -1967,7 +1967,7 @@ class ERP5Generator(PortalGenerator):
portal = self.klass(id=id) portal = self.klass(id=id)
# Make sure reindex will not be called until business templates # Make sure reindex will not be called until business templates
# will be installed # will be installed
setattr(portal, 'isIndexable', ConstantGetter('isIndexable', value=False)) setattr(portal, 'isIndexingRequired', ConstantGetter('isIndexingRequired', value=False))
# This is only used to refine log level. # This is only used to refine log level.
# Has no functional use, and should never have any: # Has no functional use, and should never have any:
...@@ -2259,7 +2259,7 @@ class ERP5Generator(PortalGenerator): ...@@ -2259,7 +2259,7 @@ class ERP5Generator(PortalGenerator):
# When no SQL connection was define on the site, # When no SQL connection was define on the site,
# we don't want to make it crash # we don't want to make it crash
if p.erp5_sql_connection_type is not None: if p.erp5_sql_connection_type is not None:
setattr(p, 'isIndexable', ConstantGetter('isIndexable', value=True)) setattr(p, 'isIndexingRequired', ConstantGetter('isIndexingRequired', value=True))
# Clear portal ids sql table, like this we do not take # Clear portal ids sql table, like this we do not take
# ids for a previously created web site # ids for a previously created web site
p.portal_ids.clearGenerator(all=True) p.portal_ids.clearGenerator(all=True)
......
...@@ -192,7 +192,8 @@ class ERP5Catalog(Folder, Catalog): ...@@ -192,7 +192,8 @@ class ERP5Catalog(Folder, Catalog):
_setPropValue = Catalog._setPropValue _setPropValue = Catalog._setPropValue
getProperty = Folder.getProperty getProperty = Folder.getProperty
_updateProperty = PropertyManager._updateProperty _updateProperty = PropertyManager._updateProperty
isIndexable = Catalog.isIndexable # We don't want to index catalog as it might create circular dependencies
isIndexable = 0
__class_init__ = Catalog.__class_init__ __class_init__ = Catalog.__class_init__
def __init__(self, id, title='', container=None): def __init__(self, id, title='', container=None):
......
...@@ -2823,7 +2823,7 @@ class Base( CopyContainer, ...@@ -2823,7 +2823,7 @@ class Base( CopyContainer,
""" """
Reindexes an object - also useful for testing Reindexes an object - also useful for testing
""" """
root_indexable = int(getattr(self.getPortalObject(),'isIndexable',1)) root_indexable = int(getattr(self.getPortalObject(),'isIndexingRequired',1))
if self.isIndexable and root_indexable: if self.isIndexable and root_indexable:
#LOG("immediateReindexObject",0,self.getRelativeUrl()) #LOG("immediateReindexObject",0,self.getRelativeUrl())
# Reindex result should not depend on the user # Reindex result should not depend on the user
......
...@@ -1273,8 +1273,8 @@ class Catalog(Folder, ...@@ -1273,8 +1273,8 @@ class Catalog(Folder,
uid_list = [x.uid for x in method(count = UID_BUFFER_SIZE, instance_id = instance_id) if x.uid != 0] uid_list = [x.uid for x in method(count = UID_BUFFER_SIZE, instance_id = instance_id) if x.uid != 0]
uid_buffer.extend(uid_list) uid_buffer.extend(uid_list)
security.declarePrivate('isIndexable') security.declarePrivate('isIndexingRequired')
def isIndexable(self): def isIndexingRequired(self):
""" """
This is required to check in many methods that This is required to check in many methods that
the site root and zope root are indexable the site root and zope root are indexable
...@@ -1282,8 +1282,8 @@ class Catalog(Folder, ...@@ -1282,8 +1282,8 @@ class Catalog(Folder,
zope_root = self.getZopeRoot() zope_root = self.getZopeRoot()
site_root = self.getSiteRoot() # XXX-JPS - Why don't we use getPortalObject here ? site_root = self.getSiteRoot() # XXX-JPS - Why don't we use getPortalObject here ?
root_indexable = int(getattr(zope_root, 'isIndexable', 1)) root_indexable = int(getattr(zope_root, 'isIndexingRequired', 1))
site_indexable = int(getattr(site_root, 'isIndexable', 1)) site_indexable = int(getattr(site_root, 'isIndexingRequired', 1))
if not (root_indexable and site_indexable): if not (root_indexable and site_indexable):
return False return False
return True return True
...@@ -1330,7 +1330,7 @@ class Catalog(Folder, ...@@ -1330,7 +1330,7 @@ class Catalog(Folder,
Similar problems may happen with relations and acquisition of uid values (ex. order_uid) Similar problems may happen with relations and acquisition of uid values (ex. order_uid)
with the risk of graph loops with the risk of graph loops
""" """
if not self.isIndexable(): if not self.isIndexingRequired():
return None return None
klass = self.__class__ klass = self.__class__
...@@ -1510,7 +1510,7 @@ class Catalog(Folder, ...@@ -1510,7 +1510,7 @@ class Catalog(Folder,
LOG('ZSLQCatalog.SQLCatalog:catalogObjectList', WARNING, LOG('ZSLQCatalog.SQLCatalog:catalogObjectList', WARNING,
'idxs is ignored in this function and is only provided to be compatible with CMFCatalogAware.reindexObject.') 'idxs is ignored in this function and is only provided to be compatible with CMFCatalogAware.reindexObject.')
if not self.isIndexable(): if not self.isIndexingRequired():
return return
# Reminder about optimization: It might be possible to issue just one # Reminder about optimization: It might be possible to issue just one
...@@ -1771,7 +1771,7 @@ class Catalog(Folder, ...@@ -1771,7 +1771,7 @@ class Catalog(Folder,
""" """
Set the path as deleted Set the path as deleted
""" """
if not self.isIndexable(): if not self.isIndexingRequired():
return None return None
if uid is None and path is not None: if uid is None and path is not None:
...@@ -1804,7 +1804,7 @@ class Catalog(Folder, ...@@ -1804,7 +1804,7 @@ class Catalog(Folder,
XXX Add filter of methods XXX Add filter of methods
""" """
if not self.isIndexable(): if not self.isIndexingRequired():
return None return None
if uid is None and path is not None: if uid is None and path is not None:
......
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