Search code examples
python-2.7plonezope

Python Could not import class


After transfer zope2 app from ubuntu12 to centos7, i get some errors that indicate that the classes are not loaded. How to check if all required libs of python are imported? How to fix these errors:

 WARNING OFS.Uninstalled Could not import class 'Photos' from module 'Products.Ezonus.projektai2.ezonus2.control.system.Photos'
------
 WARNING OFS.Uninstalled Could not import class 'FailuArchyvas' from module 'Products.Ezonus.projektai2.ezonus2.control.system.FailuArchyvas'

Solution

  • You are getting some kind of exception when these Python modules are being imported. To debug, you can find ClassFactory.py which is part of Zope2 and modify it directly to display the exact error message:

    ##############################################################################
    #
    # Copyright (c) 2002 Zope Foundation and Contributors.
    # 
    # This software is subject to the provisions of the Zope Public License,
    # Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
    # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
    # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
    # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
    # FOR A PARTICULAR PURPOSE
    # 
    ##############################################################################
    """Zope Framework Class Finder
    """
    import OFS.Uninstalled
    
    def ClassFactory(jar, module, name,
                      _silly=('__doc__',), _globals={},
                      ):
    
        # Add the following code:
        if module in [
            'Products.Ezonus.projektai2.ezonus2.control.system.Photos',
            'Products.Ezonus.projektai2.ezonus2.control.system.FailuArchyvas'
        ]:
            m=__import__(module, _globals, _globals, _silly)
        # ^^^
    
        try:
            m=__import__(module, _globals, _globals, _silly)
            return getattr(m, name)
        except:
            return OFS.Uninstalled.Broken(jar, None, (module, name))
    

    Where, for me, the exact file path was eggs/Zope2-2.13.22-py2.7.egg/Zope2/App/ClassFactory.py.

    Most likely, you are missing some Ubuntu packages which need to be installed.