# HG changeset patch # User Aurelien Campeas # Date 1381235105 -7200 # Node ID e84414be8506d152705a32978a23875cb45abd0d # Parent af36f459d2f0faed6d9c44e8f3250e3163cac0d8 [serverctl] complete the schema-diff command with options that will fix & enhance it. Notably: - filter out eids (doesn't make sense for the filesystem schema) - handle permissions, trying to detect the default ones Needs yams #174042. Closes #2996547. diff -r af36f459d2f0 -r e84414be8506 server/serverctl.py --- a/server/serverctl.py Fri Oct 18 16:58:48 2013 +0200 +++ b/server/serverctl.py Tue Oct 08 14:25:05 2013 +0200 @@ -1065,6 +1065,25 @@ if val: print key, ':', val + + +def permissionshandler(relation, perms): + from yams.schema import RelationDefinitionSchema + from yams.buildobjs import DEFAULT_ATTRPERMS + from cubicweb.schema import (PUB_SYSTEM_ENTITY_PERMS, PUB_SYSTEM_REL_PERMS, + PUB_SYSTEM_ATTR_PERMS, RO_REL_PERMS, RO_ATTR_PERMS) + defaultrelperms = (DEFAULT_ATTRPERMS, PUB_SYSTEM_REL_PERMS, + PUB_SYSTEM_ATTR_PERMS, RO_REL_PERMS, RO_ATTR_PERMS) + defaulteperms = (PUB_SYSTEM_ENTITY_PERMS,) + # canonicalize vs str/unicode + for p in ('read', 'add', 'update', 'delete'): + rule = perms.get(p) + if rule: + perms[p] = tuple(str(x) if isinstance(x, basestring) else x + for x in rule) + return perms, perms in defaultrelperms or perms in defaulteperms + + class SchemaDiffCommand(Command): """Generate a diff between schema and fsschema description. @@ -1085,7 +1104,7 @@ repo, cnx = repo_cnx(config) session = repo._get_session(cnx.sessionid, setcnxset=True) fsschema = config.load_schema(expand_cubes=True) - schema_diff(repo.schema, fsschema, diff_tool) + schema_diff(fsschema, repo.schema, permissionshandler, diff_tool, ignore=('eid',)) for cmdclass in (CreateInstanceDBCommand, InitInstanceCommand,