Commit bd5e4c85 authored by Klaus Wölfel's avatar Klaus Wölfel Committed by Ivan Tyagov

Resolve all objects in portal_callables

parent fa172b02
......@@ -30,7 +30,7 @@ from Acquisition import aq_base
during the same request.
"""
def _initializeCache(skin_tool, skin_folder_id_list):
def _initializeCache(portal_callables, skin_tool, skin_folder_id_list):
skin_list = {}
for skin_folder_id in skin_folder_id_list[::-1]:
try:
......@@ -40,6 +40,9 @@ def _initializeCache(skin_tool, skin_folder_id_list):
' but does not exist.' % skin_folder_id)
else:
skin_list.update(dict.fromkeys(skin_folder.objectIds(), skin_folder_id))
# update skin_list with objects in portal_callables
if portal_callables is not None:
skin_list.update(dict.fromkeys(portal_callables.objectIds(), "portal_callables"))
return skin_list
def CMFCoreSkinnableSkinnableObjectManager_initializeCache(self):
......@@ -50,10 +53,13 @@ def CMFCoreSkinnableSkinnableObjectManager_initializeCache(self):
if portal_skins is None:
return
portal_skins = portal_skins.aq_base
portal_callables = getattr(self, 'portal_callables', None)
if portal_callables is not None:
portal_callables = portal_callables.aq_base
skin_selection_mapping = {}
for selection_name, skin_folder_id_string in portal_skins._getSelections().iteritems():
skin_selection_mapping[selection_name] = _initializeCache(portal_skins,
skin_folder_id_string.split(','))
skin_selection_mapping[selection_name] = _initializeCache(portal_callables,
portal_skins, skin_folder_id_string.split(','))
portal_skins._v_skin_location_list = skin_selection_mapping
return skin_selection_mapping
......@@ -79,7 +85,8 @@ def skinResolve(self, selection, name):
if selection in skin_selection_mapping or \
isinstance(selection, basestring):
return
skin_list = portal_skins._getSelections()[selection[0]].split(',')
skin_list = portal_skins._getSelections()[selection[0]].split(',') \
+ ['portal_callables']
skin_selection_mapping[selection] = skin_list = _initializeCache(
portal_skins, skin_list[1+skin_list.index(selection[1]):])
try:
......@@ -88,6 +95,8 @@ def skinResolve(self, selection, name):
return
reset = True
try:
if skin_folder_id == "portal_callables":
return aq_base(getattr(aq_base(self.portal_callables), name))
return aq_base(getattr(getattr(portal_skins, skin_folder_id), name))
except AttributeError:
if reset:
......
......@@ -59,7 +59,8 @@ def CMFCoreSkinsTool__updateCacheEntry(self, container_id, object_id):
if not isinstance(selection_name, basestring):
del skin_location_list[selection_name]
for selection_name, skin_folder_id_string in self._getSelections().iteritems():
skin_folder_id_list = skin_folder_id_string.split(',')
# Add portal_callables to every selection
skin_folder_id_list = skin_folder_id_string.split(',') + ['portal_callables']
if container_id in skin_folder_id_list:
skin_folder_id_list.reverse()
this_folder_index = skin_folder_id_list.index(container_id)
......
  • @klaus , @Tyagov : Quick action needed.

    Dear Klaus and Ivan. I had a nicely working development instance. ERP5 code, at least on the filesystem was just 2 or 3 weeks old. After updating erp5 products code, after zope restart nothing works any longer.

    If I take code right before this commit, my instance is working. With this commit, the ERP5 instance is broken, and I have this in logs :

    ...
        skin_selection_mapping = self.initializeCache()
      File "/srv/slapgrid/slappart4/srv/runner/software/f055e2467707d7418e4513bc715f55b5/parts/erp5/product/ERP5Type/patches/CMFCoreSkinnable.py", li
    ne 56, in CMFCoreSkinnableSkinnableObjectManager_initializeCache
        portal_callables = getattr(self, 'portal_callables', None)
      File "/srv/slapgrid/slappart4/srv/runner/software/f055e2467707d7418e4513bc715f55b5/parts/erp5/product/ERP5Type/patches/CMFCoreSkinnable.py", li
    ne 122, in CMFCoreSkinnableSkinnableObjectManager___getattr__
        object = skinResolve(self, skin_selection_name, name)
      File "/srv/slapgrid/slappart4/srv/runner/software/f055e2467707d7418e4513bc715f55b5/parts/erp5/product/ERP5Type/patches/CMFCoreSkinnable.py", li
    ne 79, in skinResolve
        skin_selection_mapping = self.initializeCache()
      File "/srv/slapgrid/slappart4/srv/runner/software/f055e2467707d7418e4513bc715f55b5/parts/erp5/product/ERP5Type/patches/CMFCoreSkinnable.py", li
    ne 56, in CMFCoreSkinnableSkinnableObjectManager_initializeCache
        portal_callables = getattr(self, 'portal_callables', None)
      File "/srv/slapgrid/slappart4/srv/runner/software/f055e2467707d7418e4513bc715f55b5/parts/erp5/product/ERP5Type/patches/CMFCoreSkinnable.py", li
    ne 122, in CMFCoreSkinnableSkinnableObjectManager___getattr__
        object = skinResolve(self, skin_selection_name, name)
      File "/srv/slapgrid/slappart4/srv/runner/software/f055e2467707d7418e4513bc715f55b5/parts/erp5/product/ERP5Type/patches/CMFCoreSkinnable.py", li
    ne 78, in skinResolve
        ' This should not happen often. Current thread id:%X' % get_ident())
      File "/srv/slapgrid/slappart4/srv/runner/software/f055e2467707d7418e4513bc715f55b5/eggs/zLOG-2.11.2-py2.7.egg/zLOG/__init__.py", line 135, in L
    OG  
        log_write(subsystem, severity, summary, detail, error)
      File "/srv/slapgrid/slappart4/srv/runner/software/f055e2467707d7418e4513bc715f55b5/eggs/zLOG-2.11.2-py2.7.egg/zLOG/EventLogger.py", line 44, in
     log_write
        logger = logging.getLogger(subsystem)
      File "/srv/slapgrid/slappart4/srv/runner/software/f055e2467707d7418e4513bc715f55b5/parts/python2.7/lib/python2.7/logging/__init__.py", line 157
    4, in getLogger
        return Logger.manager.getLogger(name)
      File "/srv/slapgrid/slappart4/srv/runner/software/f055e2467707d7418e4513bc715f55b5/parts/python2.7/lib/python2.7/logging/__init__.py", line 103
    7, in getLogger
        if not isinstance(name, basestring):
    RuntimeError: maximum recursion depth exceeded while calling a Python object

    It seems that another commit after fix this infinite recursion. But if I switch taking the very latest ERP5 commit (d7cd7f65), my instance is still not working (not accessible at all, accessing https://my_domain/my_site/view just give the Zope Quick Start page instead of showing ERP5 front page ! ) and I have in logs every second :

    2017-09-08 11:51:33,027 INFO Zope Ready to handle requests                                                                                       
    ------                                                                                                                                           
    2017-09-08 11:51:35,320 INFO ZServer Timerserver ready, starting timer services.                                                                 
    ------                                                                                                                                           
    2017-09-08 11:51:42,087 INFO ERP5Type.Tool.ComponentTool Resetting Components                                                                    
    ------                                                                                                                                           
    2017-09-08 11:51:42,168 INFO ERP5Type.dynamic Resetting dynamic classes                                                                          
    ------                                                                                                                                           
    2017-09-08 11:51:42,644 ERROR ActivityTool process_timer received an exception                                                                   
    Traceback (most recent call last):                                                                                                               
      File "/srv/slapgrid/slappart4/srv/runner/software/f055e2467707d7418e4513bc715f55b5/parts/erp5/product/CMFActivity/ActivityTool.py", line 1040, 
    in process_timer                                                                                                                                 
        self.tic(processing_node_list.index(currentNode) + 1)                                                                                        
      File "/srv/slapgrid/slappart4/srv/runner/software/f055e2467707d7418e4513bc715f55b5/parts/erp5/product/CMFActivity/ActivityTool.py", line 1093, 
    in tic                                                                                                                                           
        for last in sorted(activity_dict.values(), key=sort_key):                                                                                    
      File "/srv/slapgrid/slappart4/srv/runner/software/f055e2467707d7418e4513bc715f55b5/parts/erp5/product/CMFActivity/ActivityTool.py", line 1090, 
    in sort_key                                                                                                                                      
        return activity.getPriority(self), activity is last                                                                                          
      File "/srv/slapgrid/slappart4/srv/runner/software/f055e2467707d7418e4513bc715f55b5/parts/erp5/product/CMFActivity/Activity/SQLBase.py", line 23
    9, in getPriority                                                                                                                                
        result = activity_tool.SQLBase_getPriority(table=self.sql_table)                                                                             
    AttributeError: SQLBase_getPriority                                                                                                              
                                             

    May be everything just fails because portal_callables is missing on my ERP5 site.

    If this is the case, I would suggest to add automatic migration for having a portal_callables tool without doing anything. The installation of portal_callables by business template is probably not enough, because right now with a broken site we can not update any bt.

    Could you please have a look ?

  • @seb , I am checking with Klaus.

  • @Tyagov You can also check if 88c8b4f0 is related, because this is different from our production environment. /cc @seb

  • @seb, @klaus - I think this is the fix. I also had the issue with old ERP5 instance and with this fix ERP5 site is usable (i.e. upgrade of erp5_core is possible).

    https://lab.nexedi.com/Tyagov/erp5/commit/66a3705e2271afd04d48a916e11ca70037242adc

    I have unit tests and when ready I make a MR

  • @Tyagov , I confirm your patch is enough to make my ERP5 instance accessible again. Thanks for quick patch ! It would be good to merge it into master today.

  • I waited for tests,

    I merged as well another small fix, too.

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