goa/goavreg.py
branchtls-sprint
changeset 1802 d628defebc17
parent 9 1901fcf55ed4
child 1977 606923dff11b
equal deleted inserted replaced
1801:672acc730ce5 1802:d628defebc17
     1 """goa specific registry
     1 """goa specific registry
     2 
     2 
     3 :organization: Logilab
     3 :organization: Logilab
     4 :copyright: 2008 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
     4 :copyright: 2008-2009 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
     5 :contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr
     5 :contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr
     6 """
     6 """
     7 __docformat__ = "restructuredtext en"
     7 __docformat__ = "restructuredtext en"
     8 
     8 
     9 from os import listdir
     9 from os import listdir
    17     if cube is None:
    17     if cube is None:
    18         return module
    18         return module
    19     return 'cubes.%s.%s' % (cube, module)
    19     return 'cubes.%s.%s' % (cube, module)
    20 
    20 
    21 class GAERegistry(CubicWebRegistry):
    21 class GAERegistry(CubicWebRegistry):
    22     
    22 
    23     def set_schema(self, schema):
    23     def set_schema(self, schema):
    24         """disable reload hooks of cubicweb registry set_schema method"""
    24         """disable reload hooks of cubicweb registry set_schema method"""
    25         self.schema = schema
    25         self.schema = schema
    26 
    26 
    27     def load(self, applroot):
    27     def load(self, applroot):
    35         self.load_directory(join(CW_SOFTWARE_ROOT, 'goa', 'appobjects'),
    35         self.load_directory(join(CW_SOFTWARE_ROOT, 'goa', 'appobjects'),
    36                             'cubicweb.goa.appobjects')
    36                             'cubicweb.goa.appobjects')
    37         for cube in reversed(self.config.cubes()):
    37         for cube in reversed(self.config.cubes()):
    38             self.load_cube(cube)
    38             self.load_cube(cube)
    39         self.load_application(applroot)
    39         self.load_application(applroot)
    40         
    40 
    41     def load_directory(self, directory, cube, skip=()):
    41     def load_directory(self, directory, cube, skip=()):
    42         for filename in listdir(directory):
    42         for filename in listdir(directory):
    43             if filename[-3:] == '.py' and not filename in skip:
    43             if filename[-3:] == '.py' and not filename in skip:
    44                 self._import('%s.%s' % (cube, filename[:-3]))
    44                 self._import('%s.%s' % (cube, filename[:-3]))
    45 
    45 
    68                     self.load_directory(abspath, _pkg_name(cube, filename))
    68                     self.load_directory(abspath, _pkg_name(cube, filename))
    69         if loadschema:
    69         if loadschema:
    70             # when using db.Model defined schema, the defined class is used as
    70             # when using db.Model defined schema, the defined class is used as
    71             # entity class as well and so have to be registered
    71             # entity class as well and so have to be registered
    72             self._import(_pkg_name(cube, 'schema'))
    72             self._import(_pkg_name(cube, 'schema'))
    73 
       
    74 
       
    75