Commit a5ce091b authored by Nicolas Delaby's avatar Nicolas Delaby

get rid of CachingMethod, replace them by decorator for consistency.



git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@36144 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 86d24025
...@@ -941,30 +941,30 @@ class Catalog(Folder, ...@@ -941,30 +941,30 @@ class Catalog(Folder,
return catalog_schema_dict[table] return catalog_schema_dict[table]
@caching_instance_method(id='SQLCatalog.getColumnIds',
cache_factory='erp5_content_long')
def getColumnIds(self): def getColumnIds(self):
""" """
Calls the show column method and returns dictionnary of Calls the show column method and returns dictionnary of
Field Ids Field Ids
""" """
def _getColumnIds(): keys = {}
keys = {} for table in self.getCatalogSearchTableIds():
for table in self.getCatalogSearchTableIds(): field_list = self._getCatalogSchema(table=table)
field_list = self._getCatalogSchema(table=table) for field in field_list:
for field in field_list: keys[field] = None
keys[field] = None keys['%s.%s' % (table, field)] = None # Is this inconsistent ?
keys['%s.%s' % (table, field)] = None # Is this inconsistent ? for related in self.getSQLCatalogRelatedKeyList():
for related in self.getSQLCatalogRelatedKeyList(): related_tuple = related.split('|')
related_tuple = related.split('|') related_key = related_tuple[0].strip()
related_key = related_tuple[0].strip() keys[related_key] = None
keys[related_key] = None for scriptable in self.getSQLCatalogScriptableKeyList():
for scriptable in self.getSQLCatalogScriptableKeyList(): scriptable_tuple = scriptable.split('|')
scriptable_tuple = scriptable.split('|') scriptable = scriptable_tuple[0].strip()
scriptable = scriptable_tuple[0].strip() keys[scriptable] = None
keys[scriptable] = None keys = list(keys.keys())
keys = keys.keys() keys.sort()
keys.sort() return keys
return keys
return CachingMethod(_getColumnIds, id='SQLCatalog.getColumnIds', cache_factory='erp5_content_long')()[:]
@profiler_decorator @profiler_decorator
@transactional_cache_decorator('SQLCatalog.getColumnMap') @transactional_cache_decorator('SQLCatalog.getColumnMap')
...@@ -1815,24 +1815,23 @@ class Catalog(Folder, ...@@ -1815,24 +1815,23 @@ class Catalog(Folder,
""" """
return self.sql_catalog_scriptable_keys return self.sql_catalog_scriptable_keys
@caching_instance_method(id='SQLCatalog.getTableIndex',
cache_factory='erp5_content_long')
def getTableIndex(self, table): def getTableIndex(self, table):
""" """
Return a map between index and column for a given table Return a map between index and column for a given table
""" """
def _getTableIndex(table): table_index = {}
table_index = {} method = getattr(self, self.sql_catalog_index, '')
method = getattr(self, self.sql_catalog_index, '') if method in ('', None):
if method in ('', None): return {}
return {} index = list(method(table=table))
index = list(method(table=table)) for line in index:
for line in index: if table_index.has_key(line.KEY_NAME):
if table_index.has_key(line.KEY_NAME): table_index[line.KEY_NAME].append(line.COLUMN_NAME)
table_index[line.KEY_NAME].append(line.COLUMN_NAME) else:
else: table_index[line.KEY_NAME] = [line.COLUMN_NAME,]
table_index[line.KEY_NAME] = [line.COLUMN_NAME,] return table_index.copy()
return table_index
return CachingMethod(_getTableIndex, id='SQLCatalog.getTableIndex', \
cache_factory='erp5_content_long')(table=table).copy()
@profiler_decorator @profiler_decorator
def isValidColumn(self, column_id): def isValidColumn(self, column_id):
......
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