[management] fix vocab: use cube instead of package
# copyright 2003-2010 LOGILAB S.A. (Paris, FRANCE), all rights reserved.# contact http://www.logilab.fr/ -- mailto:contact@logilab.fr## This file is part of CubicWeb.## CubicWeb is free software: you can redistribute it and/or modify it under the# terms of the GNU Lesser General Public License as published by the Free# Software Foundation, either version 2.1 of the License, or (at your option)# any later version.## CubicWeb is distributed in the hope that it will be useful, but WITHOUT# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more# details.## You should have received a copy of the GNU Lesser General Public License along# with CubicWeb. If not, see <http://www.gnu.org/licenses/>."""goa specific registry"""__docformat__="restructuredtext en"fromosimportlistdirfromos.pathimportjoin,isdirfromcubicwebimportCW_SOFTWARE_ROOTfromcubicweb.cwvregimportCubicWebVRegistrydef_pkg_name(cube,module):ifcubeisNone:returnmodulereturn'cubes.%s.%s'%(cube,module)classGAEVRegistry(CubicWebVRegistry):defset_schema(self,schema):"""disable reload hooks of cubicweb registry set_schema method"""self.schema=schemadefload(self,applroot):fromcubicweb.goaimportdbself.load_module(db)# AnyEntity class# explicit loading, we don't want to load __init__.pyself.load_directory(join(CW_SOFTWARE_ROOT,'entities'),'cubicweb.entities',skip=('__init__.py',))self.load_directory(join(CW_SOFTWARE_ROOT,'web','views'),'cubicweb.web.views')self.load_directory(join(CW_SOFTWARE_ROOT,'goa','appobjects'),'cubicweb.goa.appobjects')forcubeinreversed(self.config.cubes()):self.load_cube(cube)self.load_instance(applroot)defload_directory(self,directory,cube,skip=()):forfilenameinlistdir(directory):iffilename[-3:]=='.py'andnotfilenameinskip:self._import('%s.%s'%(cube,filename[:-3]))defload_cube(self,cube):self._auto_load(self.config.cube_dir(cube),cubeinself.config['included-cubes'],cube)defload_instance(self,applroot):self._auto_load(applroot,self.config['schema-type']=='dbmodel')def_import(self,modname):obj=__import__(modname)forattrinmodname.split('.')[1:]:obj=getattr(obj,attr)self.load_module(obj)def_auto_load(self,path,loadschema,cube=None):vobjpath=self.config.cube_appobject_pathforfilenameinlistdir(path):iffilename[-3:]=='.py'andfilename[:-3]invobjpath:self._import(_pkg_name(cube,filename[:-3]))else:abspath=join(path,filename)ifisdir(abspath)andfilenameinvobjpath:self.load_directory(abspath,_pkg_name(cube,filename))ifloadschema:# when using db.Model defined schema, the defined class is used as# entity class as well and so have to be registeredself._import(_pkg_name(cube,'schema'))