to make cw schemas importable, they have to be installed w/ cw code, not in /usr/share/cubicweb/schemas
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Fri, 07 Aug 2009 13:58:28 +0200
changeset 2730 bb6fcb8c5d71
parent 2729 d3dbd135f319
child 2731 815b93271338
to make cw schemas importable, they have to be installed w/ cw code, not in /usr/share/cubicweb/schemas
MANIFEST.in
debian/cubicweb-server.install.in
devtools/apptest.py
goa/dbmyams.py
schema.py
server/__init__.py
server/serverconfig.py
server/test/unittest_schemaserial.py
test/unittest_schema.py
--- a/MANIFEST.in	Fri Aug 07 12:51:56 2009 +0200
+++ b/MANIFEST.in	Fri Aug 07 13:58:28 2009 +0200
@@ -15,7 +15,7 @@
 recursive-include etwist *.xml *.html
 
 recursive-include i18n *.pot *.po
-recursive-include schemas *.py *.rel *.sql.*
+recursive-include schemas *.py *.sql.*
 
 recursive-include common/test/data *
 recursive-include entities/test/data *
--- a/debian/cubicweb-server.install.in	Fri Aug 07 12:51:56 2009 +0200
+++ b/debian/cubicweb-server.install.in	Fri Aug 07 13:58:28 2009 +0200
@@ -1,4 +1,4 @@
 debian/tmp/usr/lib/PY_VERSION/site-packages/cubicweb/server/ usr/lib/PY_VERSION/site-packages/cubicweb
 debian/tmp/usr/lib/PY_VERSION/site-packages/cubicweb/sobjects/ usr/lib/PY_VERSION/site-packages/cubicweb
-debian/tmp/usr/share/cubicweb/schemas/ usr/share/cubicweb/
+debian/tmp/usr/lib/PY_VERSION/site-packages/cubicweb/schemas/ usr/lib/PY_VERSION/site-packages/cubicweb
 debian/tmp/usr/share/cubicweb/migration/ usr/share/cubicweb/
--- a/devtools/apptest.py	Fri Aug 07 12:51:56 2009 +0200
+++ b/devtools/apptest.py	Fri Aug 07 13:58:28 2009 +0200
@@ -282,6 +282,7 @@
         self.session().unsafe_execute('DELETE Any X WHERE X eid > %s' % self.maxeid)
         self.commit()
 
+    # global resources accessors ###############################################
 
 # XXX
 try:
--- a/goa/dbmyams.py	Fri Aug 07 12:51:56 2009 +0200
+++ b/goa/dbmyams.py	Fri Aug 07 13:58:28 2009 +0200
@@ -160,12 +160,6 @@
 import os
 from cubicweb import CW_SOFTWARE_ROOT
 
-if os.environ.get('APYCOT_ROOT'):
-    SCHEMAS_LIB_DIRECTORY = join(os.environ['APYCOT_ROOT'],
-                                 'local', 'share', 'cubicweb', 'schemas')
-else:
-    SCHEMAS_LIB_DIRECTORY = join(CW_SOFTWARE_ROOT, 'schemas')
-
 def load_schema(config, schemaclasses=None, extrahook=None):
     """high level method to load all the schema for a lax instance"""
     # IMPORTANT NOTE: dbmodel schemas must be imported **BEFORE**
@@ -174,7 +168,7 @@
     for compname in config['included-cubes']:
         __import__('%s.schema' % compname)
     loader = GaeSchemaLoader(use_gauthservice=config['use-google-auth'], db=db)
-    loader.lib_directory = SCHEMAS_LIB_DIRECTORY
+    loader.lib_directory = join(CW_SOFTWARE_ROOT, 'schemas')
     if schemaclasses is not None:
         for cls in schemaclasses:
             loader.load_dbmodel(cls.__name__, goadb.extract_dbmodel(cls))
@@ -188,7 +182,7 @@
                      'read_permission', 'add_permission',
                      'delete_permission', 'update_permission'):
         loader.import_yams_schema(erschema, 'bootstrap')
-    loader.handle_file(join(SCHEMAS_LIB_DIRECTORY, 'base.py'))
+    loader.handle_file(join(CW_SOFTWARE_ROOT, 'schemas', 'base.py'))
     cubes = config['included-yams-cubes']
     for cube in reversed(config.expand_cubes(cubes)):
         config.info('loading cube %s', cube)
--- a/schema.py	Fri Aug 07 12:51:56 2009 +0200
+++ b/schema.py	Fri Aug 07 13:58:28 2009 +0200
@@ -14,6 +14,7 @@
 from warnings import warn
 
 from logilab.common.decorators import cached, clear_cache, monkeypatch
+from logilab.common.logging_ext import set_log_methods
 from logilab.common.deprecation import deprecated
 from logilab.common.compat import any
 
@@ -26,8 +27,8 @@
 
 from rql import parse, nodes, RQLSyntaxError, TypeResolverException
 
+import cubicweb
 from cubicweb import ETYPE_NAME_MAP, ValidationError, Unauthorized
-from cubicweb import set_log_methods
 
 # XXX <3.2 bw compat
 from yams import schema
@@ -849,7 +850,7 @@
         """return a Schema instance from the schema definition read
         from <directory>
         """
-        self.lib_directory = config.schemas_lib_dir()
+        self.lib_directory = join(cubicweb.CW_SOFTWARE_ROOT, 'schemas')
         return super(BootstrapSchemaLoader, self).load(
             path, config.appid, register_base_types=False, **kwargs)
 
--- a/server/__init__.py	Fri Aug 07 12:51:56 2009 +0200
+++ b/server/__init__.py	Fri Aug 07 13:58:28 2009 +0200
@@ -12,10 +12,15 @@
 
 import sys
 from os.path import join, exists
+from glob import glob
 
 from logilab.common.modutils import LazyObject
 from logilab.common.textutils import splitstrip
 
+from yams import BASE_GROUPS
+
+from cubicweb import CW_SOFTWARE_ROOT
+
 # server-side debugging #########################################################
 
 # server debugging flags. They may be combined using binary operators.
@@ -92,8 +97,6 @@
     with the minimal set of entities (ie at least the schema, base groups and
     a initial user)
     """
-    from glob import glob
-    from yams import BASE_GROUPS
     from cubicweb.dbapi import in_memory_cnx
     from cubicweb.server.repository import Repository
     from cubicweb.server.utils import manager_userpasswd
@@ -140,7 +143,7 @@
         #               if not repo.system_source.support_entity(str(e))])
     sqlexec(schemasql, execute, pbtitle=_title)
     # install additional driver specific sql files
-    for fpath in glob(join(config.schemas_lib_dir(), '*.sql.%s' % driver)):
+    for fpath in glob(join(CW_SOFTWARE_ROOT, 'schemas', '*.sql.%s' % driver)):
         print '-> installing', fpath
         sqlexec(open(fpath).read(), execute, False, delimiter=';;')
     for directory in config.cubes_path():
--- a/server/serverconfig.py	Fri Aug 07 12:51:56 2009 +0200
+++ b/server/serverconfig.py	Fri Aug 07 13:58:28 2009 +0200
@@ -77,12 +77,9 @@
     name = 'repository'
     if os.environ.get('APYCOT_ROOT'):
         root = os.environ['APYCOT_ROOT']
-        SCHEMAS_LIB_DIR = '%s/local/share/cubicweb/schemas/' % root
     elif CubicWebConfiguration.mode == 'dev':
-        SCHEMAS_LIB_DIR = join(CW_SOFTWARE_ROOT, 'schemas')
         BACKUP_DIR = CubicWebConfiguration.RUNTIME_DIR
     else:
-        SCHEMAS_LIB_DIR = '/usr/share/cubicweb/schemas/'
         BACKUP_DIR = '/var/lib/cubicweb/backup/'
 
     cubicweb_appobject_path = CubicWebConfiguration.cubicweb_appobject_path | set(['sobjects'])
@@ -208,11 +205,6 @@
         self._enabled_sources = sourceuris
         clear_cache(self, 'sources')
 
-    @classmethod
-    def schemas_lib_dir(cls):
-        """instance schema directory"""
-        return env_path('CW_SCHEMA_LIB', cls.SCHEMAS_LIB_DIR, 'schemas')
-
     def bootstrap_cubes(self):
         from logilab.common.textutils import splitstrip
         for line in file(join(self.apphome, 'bootstrap_cubes')):
--- a/server/test/unittest_schemaserial.py	Fri Aug 07 12:51:56 2009 +0200
+++ b/server/test/unittest_schemaserial.py	Fri Aug 07 13:58:28 2009 +0200
@@ -13,7 +13,6 @@
 loader = CubicWebSchemaLoader()
 config = TestServerConfiguration('data')
 config.bootstrap_cubes()
-loader.lib_directory = config.schemas_lib_dir()
 schema = loader.load(config)
 
 from cubicweb.server.schemaserial import *
--- a/test/unittest_schema.py	Fri Aug 07 12:51:56 2009 +0200
+++ b/test/unittest_schema.py	Fri Aug 07 13:58:28 2009 +0200
@@ -130,7 +130,6 @@
 loader = CubicWebSchemaLoader()
 config = TestConfiguration('data')
 config.bootstrap_cubes()
-loader.lib_directory = config.schemas_lib_dir()
 
 class SQLSchemaReaderClassTest(TestCase):