Commit 653a4623 authored by Nicolas Dumazet's avatar Nicolas Dumazet

accessor generation: be more tolerant when some tools are missing

This is required to be able to bootstrap without dying.
In reality, localized accessors, or related category getters are not required
to run a site / install erp5_core and can be regenerated later.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@42365 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent bff2ac23
...@@ -1258,7 +1258,12 @@ def getExistingBaseCategoryList(portal, base_cat_list): ...@@ -1258,7 +1258,12 @@ def getExistingBaseCategoryList(portal, base_cat_list):
cache = getReadOnlyTransactionCache() cache = getReadOnlyTransactionCache()
if cache is None: if cache is None:
cache = getTransactionalVariable() cache = getTransactionalVariable()
category_tool = portal.portal_categories category_tool = getattr(portal, 'portal_categories', None)
if category_tool is None:
# most likely, accessor generation when bootstrapping a site
warnings.warn("Category Tool is missing. Accessors can not be generated.")
return ()
new_base_cat_list = [] new_base_cat_list = []
for base_cat in base_cat_list: for base_cat in base_cat_list:
key = (base_cat,) key = (base_cat,)
...@@ -2872,7 +2877,12 @@ def createTranslationLanguageAccessors(property_holder, property, ...@@ -2872,7 +2877,12 @@ def createTranslationLanguageAccessors(property_holder, property,
""" """
accessor_dict_list = [] accessor_dict_list = []
for language in portal.Localizer.get_languages(): localizer = getattr(portal, 'Localizer', None)
if localizer is None:
warnings.warn("Localizer is missing. Accessors can not be generated.")
return
for language in localizer.get_languages():
language_key = language.replace('-', '_') language_key = language.replace('-', '_')
composed_id = '%s_translated_%s' % (language_key, property['id']) composed_id = '%s_translated_%s' % (language_key, property['id'])
capitalised_compose_id = UpperCase(composed_id) capitalised_compose_id = UpperCase(composed_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