parameters: (self, fullname, path=None)
docstring: PEP-302 Finder which determines which packages and modules will be handled
      by this class. It must be done carefully to avoid handling packages and
      modules the Loader (load_module()) will not be handled later as the latter
      would raise ImportError...
  
      As per PEP-302, returns None if this Finder cannot handle the given name,
      perhaps because the Finder of another Component Package could do it or
      because this is a filesystem module...
docstring_summary: PEP-302 Finder which determines which packages and modules will be handled
      by this class. It must be done carefully to avoid handling packages and
      modules the Loader (load_module()) will not be handled later as the latter
      would raise ImportError...
docstring_tokens: PEP - 302 Finder which determines which packages and modules will be handled by this class . It must be done carefully to avoid handling packages and modules the Loader ( load_module () ) will not be handled later as the latter would raise ImportError ...
function: def find_module(self, fullname, path=None):
      """
      PEP-302 Finder which determines which packages and modules will be handled
      by this class. It must be done carefully to avoid handling packages and
      modules the Loader (load_module()) will not be handled later as the latter
      would raise ImportError...
  
      As per PEP-302, returns None if this Finder cannot handle the given name,
      perhaps because the Finder of another Component Package could do it or
      because this is a filesystem module...
      """
      import erp5.component
  
      # ZODB Components
      if not path:
        if not fullname.startswith(self._namespace_prefix):
          return None
      # FS import backward compatibility
      else:
        try:
          fullname = erp5.component.filesystem_import_dict[fullname]
        except (TypeError, KeyError):
          return None
        else:
          if not fullname.startswith(self._namespace_prefix):
            return None
  
      import_lock_held = True
      try:
        imp.release_lock()
      except RuntimeError:
        import_lock_held = False
  
      try:
        site = getSite()
  
        if erp5.component.filesystem_import_dict is None:
          filesystem_import_dict = {}
          try:
            component_tool = aq_base(site.portal_components)
          except AttributeError:
            # For old sites, just use FS Documents...
            return None
          else:
            for component in component_tool.objectValues():
              if component.getValidationState() == 'validated':
                component_module_name = '%s.%s' % (component._getDynamicModuleNamespace(),
                                                   component.getReference())
                if component.getSourceReference() is not None:
                  filesystem_import_dict[component.getSourceReference()] = component_module_name
  
                if component.getPortalType() == 'Document Component':
                  filesystem_import_dict[('Products.ERP5Type.Document.' +
                                          component.getReference())] = component_module_name
            erp5.component.filesystem_import_dict = filesystem_import_dict
  
        # __import__ will first try a relative import, for example
        # erp5.component.XXX.YYY.ZZZ where erp5.component.XXX.YYY is the current
        # Component where an import is done
        name = fullname[len(self._namespace_prefix):]
        # name=VERSION_version.REFERENCE
        if '.' in name:
          try:
            version, name = name.split('.')
            version = version[:-self.__version_suffix_len]
          except ValueError:
            return None
  
          id_ = "%s.%s.%s" % (self._id_prefix, version, name)
          # aq_base() because this should not go up to ERP5Site and trigger
          # side-effects, after all this only check for existence...
          component = getattr(aq_base(site.portal_components), id_, None)
          if component is None or component.getValidationState() not in ('modified',
                                                                         'validated'):
            return None
  
        # Skip unavailable components, otherwise Products for example could be
        # wrongly considered as importable and thus the actual filesystem class
        # ignored
        #
        # name=VERSION_version
        elif name.endswith('_version'):
          if name[:-self.__version_suffix_len] not in site.getVersionPriorityNameList():
            return None
  
        # name=REFERENCE
        else:
          component_tool = aq_base(site.portal_components)
          for version in site.getVersionPriorityNameList():
            id_ = "%s.%s.%s" % (self._id_prefix, version, name)
            component = getattr(component_tool, id_, None)
            if component is not None and component.getValidationState() in ('modified',
                                                                            'validated'):
              break
          else:
            return None
  
        return self
  
      finally:
        # Internal release of import lock at the end of import machinery will
        # fail if the hook is not acquired
        if import_lock_held:
          imp.acquire_lock()
function_tokens: def find_module ( self , fullname , path = None ) : import erp5 . component # ZODB Components if not path : if not fullname . startswith ( self . _namespace_prefix ) : return None # FS import backward compatibility else : try : fullname = erp5 . component . filesystem_import_dict [ fullname ] except ( TypeError , KeyError ) : return None else : if not fullname . startswith ( self . _namespace_prefix ) : return None import_lock_held = True try : imp . release_lock ( ) except RuntimeError : import_lock_held = False try : site = getSite ( ) if erp5 . component . filesystem_import_dict is None : filesystem_import_dict = { } try : component_tool = aq_base ( site . portal_components ) except AttributeError : # For old sites, just use FS Documents... return None else : for component in component_tool . objectValues ( ) : if component . getValidationState ( ) == 'validated' : component_module_name = '%s.%s' % ( component . _getDynamicModuleNamespace ( ) , component . getReference ( ) ) if component . getSourceReference ( ) is not None : filesystem_import_dict [ component . getSourceReference ( ) ] = component_module_name if component . getPortalType ( ) == 'Document Component' : filesystem_import_dict [ ( 'Products.ERP5Type.Document.' + component . getReference ( ) ) ] = component_module_name erp5 . component . filesystem_import_dict = filesystem_import_dict # __import__ will first try a relative import, for example # erp5.component.XXX.YYY.ZZZ where erp5.component.XXX.YYY is the current # Component where an import is done name = fullname [ len ( self . _namespace_prefix ) : ] # name=VERSION_version.REFERENCE if '.' in name : try : version , name = name . split ( '.' ) version = version [ : - self . __version_suffix_len ] except ValueError : return None id_ = "%s.%s.%s" % ( self . _id_prefix , version , name ) # aq_base() because this should not go up to ERP5Site and trigger # side-effects, after all this only check for existence... component = getattr ( aq_base ( site . portal_components ) , id_ , None ) if component is None or component . getValidationState ( ) not in ( 'modified' , 'validated' ) : return None # Skip unavailable components, otherwise Products for example could be # wrongly considered as importable and thus the actual filesystem class # ignored # # name=VERSION_version elif name . endswith ( '_version' ) : if name [ : - self . __version_suffix_len ] not in site . getVersionPriorityNameList ( ) : return None # name=REFERENCE else : component_tool = aq_base ( site . portal_components ) for version in site . getVersionPriorityNameList ( ) : id_ = "%s.%s.%s" % ( self . _id_prefix , version , name ) component = getattr ( component_tool , id_ , None ) if component is not None and component . getValidationState ( ) in ( 'modified' , 'validated' ) : break else : return None return self finally : # Internal release of import lock at the end of import machinery will # fail if the hook is not acquired if import_lock_held : imp . acquire_lock ( )