[repository] set .eid on eschema when schema is loaded from the filesystem
enforcing the contract that a repository's schema should have .eid attribute of
entity schema set to the eid of the entity used to serialize them in the db.
Before this cset, this was not true during tests or for some c-c commands where
'quick_start' is set (eg db-restore, i18ncube...).
The change in server __init__ makes this assumption true during instance
creation: the serializing code was actually setting eid on schema object, but a
reference to a previously built schema was given instead of the one for the
latest created repository.
Closes #10450092
--- a/server/__init__.py Fri Jan 29 10:06:36 2016 +0100
+++ b/server/__init__.py Thu Jan 28 18:17:30 2016 +0100
@@ -297,6 +297,9 @@
# re-login using the admin user
config._cubes = None # avoid assertion error
repo = get_repository(config=config)
+ # replace previous schema by the new repo's one. This is necessary so that we give the proper
+ # schema to `initialize_schema` above since it will initialize .eid attribute of schema elements
+ schema = repo.schema
with connect(repo, login, password=pwd) as cnx:
with cnx.security_enabled(False, False):
repo.system_source.eid = ssource.eid # redo this manually
--- a/server/repository.py Fri Jan 29 10:06:36 2016 +0100
+++ b/server/repository.py Thu Jan 28 18:17:30 2016 +0100
@@ -226,6 +226,11 @@
if not config.creating:
self.info("set fs instance'schema")
self.set_schema(config.load_schema(expand_cubes=True))
+ if not config.creating:
+ # set eids on entities schema
+ with self.internal_cnx() as cnx:
+ for etype, eid in cnx.execute('Any XN,X WHERE X is CWEType, X name XN'):
+ self.schema.eschema(etype).eid = eid
else:
# normal start: load the instance schema from the database
self.info('loading schema from the repository')