cwconfig.py
changeset 2657 de974465d381
parent 2654 6512522860aa
child 2665 0c6281487f90
equal deleted inserted replaced
2656:a93ae0f6c0ad 2657:de974465d381
   140     __metaclass__ = metaconfiguration
   140     __metaclass__ = metaconfiguration
   141     # to set in concrete configuration
   141     # to set in concrete configuration
   142     name = None
   142     name = None
   143     # log messages format (see logging module documentation for available keys)
   143     # log messages format (see logging module documentation for available keys)
   144     log_format = '%(asctime)s - (%(name)s) %(levelname)s: %(message)s'
   144     log_format = '%(asctime)s - (%(name)s) %(levelname)s: %(message)s'
   145     # nor remove vobjects based on unused interface
   145     # nor remove appobjects based on unused interface
   146     cleanup_interface_sobjects = True
   146     cleanup_interface_sobjects = True
   147 
   147 
   148     if os.environ.get('APYCOT_ROOT'):
   148     if os.environ.get('APYCOT_ROOT'):
   149         mode = 'test'
   149         mode = 'test'
   150         CUBES_DIR = '%(APYCOT_ROOT)s/local/share/cubicweb/cubes/' % os.environ
   150         CUBES_DIR = '%(APYCOT_ROOT)s/local/share/cubicweb/cubes/' % os.environ
   417             try:
   417             try:
   418                 __import__('cubes.%s' % cube)
   418                 __import__('cubes.%s' % cube)
   419             except Exception, ex:
   419             except Exception, ex:
   420                 cls.warning("can't init cube %s: %s", cube, ex)
   420                 cls.warning("can't init cube %s: %s", cube, ex)
   421 
   421 
   422     cubicweb_vobject_path = set(['entities'])
   422     cubicweb_appobject_path = set(['entities'])
   423     cube_vobject_path = set(['entities'])
   423     cube_appobject_path = set(['entities'])
   424 
   424 
   425     @classmethod
   425     @classmethod
   426     def build_vregistry_path(cls, templpath, evobjpath=None, tvobjpath=None):
   426     def build_vregistry_path(cls, templpath, evobjpath=None, tvobjpath=None):
   427         """given a list of directories, return a list of sub files and
   427         """given a list of directories, return a list of sub files and
   428         directories that should be loaded by the instance objects registry.
   428         directories that should be loaded by the instance objects registry.
   429 
   429 
   430         :param evobjpath:
   430         :param evobjpath:
   431           optional list of sub-directories (or files without the .py ext) of
   431           optional list of sub-directories (or files without the .py ext) of
   432           the cubicweb library that should be tested and added to the output list
   432           the cubicweb library that should be tested and added to the output list
   433           if they exists. If not give, default to `cubicweb_vobject_path` class
   433           if they exists. If not give, default to `cubicweb_appobject_path` class
   434           attribute.
   434           attribute.
   435         :param tvobjpath:
   435         :param tvobjpath:
   436           optional list of sub-directories (or files without the .py ext) of
   436           optional list of sub-directories (or files without the .py ext) of
   437           directories given in `templpath` that should be tested and added to
   437           directories given in `templpath` that should be tested and added to
   438           the output list if they exists. If not give, default to
   438           the output list if they exists. If not give, default to
   439           `cube_vobject_path` class attribute.
   439           `cube_appobject_path` class attribute.
   440         """
   440         """
   441         vregpath = cls.build_vregistry_cubicweb_path(evobjpath)
   441         vregpath = cls.build_vregistry_cubicweb_path(evobjpath)
   442         vregpath += cls.build_vregistry_cube_path(templpath, tvobjpath)
   442         vregpath += cls.build_vregistry_cube_path(templpath, tvobjpath)
   443         return vregpath
   443         return vregpath
   444 
   444 
   445     @classmethod
   445     @classmethod
   446     def build_vregistry_cubicweb_path(cls, evobjpath=None):
   446     def build_vregistry_cubicweb_path(cls, evobjpath=None):
   447         vregpath = []
   447         vregpath = []
   448         if evobjpath is None:
   448         if evobjpath is None:
   449             evobjpath = cls.cubicweb_vobject_path
   449             evobjpath = cls.cubicweb_appobject_path
   450         for subdir in evobjpath:
   450         for subdir in evobjpath:
   451             path = join(CW_SOFTWARE_ROOT, subdir)
   451             path = join(CW_SOFTWARE_ROOT, subdir)
   452             if exists(path):
   452             if exists(path):
   453                 vregpath.append(path)
   453                 vregpath.append(path)
   454         return vregpath
   454         return vregpath
   455 
   455 
   456     @classmethod
   456     @classmethod
   457     def build_vregistry_cube_path(cls, templpath, tvobjpath=None):
   457     def build_vregistry_cube_path(cls, templpath, tvobjpath=None):
   458         vregpath = []
   458         vregpath = []
   459         if tvobjpath is None:
   459         if tvobjpath is None:
   460             tvobjpath = cls.cube_vobject_path
   460             tvobjpath = cls.cube_appobject_path
   461         for directory in templpath:
   461         for directory in templpath:
   462             for subdir in tvobjpath:
   462             for subdir in tvobjpath:
   463                 path = join(directory, subdir)
   463                 path = join(directory, subdir)
   464                 if exists(path):
   464                 if exists(path):
   465                     vregpath.append(path)
   465                     vregpath.append(path)