Commit 073c4aa7 authored by Sylvain Thénault's avatar Sylvain Thénault
Browse files

fix long-waiting symetric typo: should be spelled symmetric. Add auto database...

fix long-waiting symetric typo: should be spelled symmetric. Add auto database migration on schema deserialization
parent 8b0ca7904820
......@@ -185,7 +185,7 @@ def _generate_schema_pot(w, vreg, schema, libconfig=None, cube=None):
# XXX also generate "creating ...' messages for actions in the
# addrelated submenu
w('# subject and object forms for each relation type\n')
w('# (no object form for final or symetric relation types)\n')
w('# (no object form for final or symmetric relation types)\n')
w('\n')
for rschema in sorted(schema.relations()):
rtype = rschema.type
......@@ -205,7 +205,7 @@ def _generate_schema_pot(w, vreg, schema, libconfig=None, cube=None):
for subjschema in rschema.subjects():
if not subjschema in libsubjects:
add_msg(w, rtype, subjschema.type)
if not (schema.rschema(rtype).final or rschema.symetric):
if not (schema.rschema(rtype).final or rschema.symmetric):
if rschema not in no_context_rtypes:
libobjects = librschema and librschema.objects() or ()
for objschema in rschema.objects():
......
......@@ -394,7 +394,7 @@ class RelationsQueriesGenerator(object):
# for each couple (subjschema, objschema), insert relations
for subj, obj in rschema.rdefs:
sym.add( (subj, obj) )
if rschema.symetric and (obj, subj) in sym:
if rschema.symmetric and (obj, subj) in sym:
continue
subjcard, objcard = rschema.rdef(subj, obj).cardinality
# process mandatory relations first
......
......@@ -16,5 +16,5 @@ class Bug(EntityType):
severity = String(vocabulary=('important', 'normal', 'minor'), default='normal')
cost = Int()
description = String(maxsize=4096, fulltextindexed=True)
identical_to = SubjectRelation('Bug', symetric=True)
identical_to = SubjectRelation('Bug', symmetric=True)
......@@ -177,7 +177,7 @@ partagés par toutes les définitions de relation de ce type) sont :
à la relation. Cela se limite donc aux relations dont la cardinalité
sujet->relation->objet vaut 0..1 ('?') ou 1..1 ('1')
* `symetric` : booléen indiquant que la relation est symétrique. i.e.
* `symmetric` : booléen indiquant que la relation est symétrique. i.e.
`X relation Y` implique `Y relation X`
Dans le cas de définitions de relations simultanée, `sujet` et `object` peuvent
......
......@@ -46,8 +46,8 @@ class CWRType(AnyEntity):
def dc_long_title(self):
stereotypes = []
_ = self._cw._
if self.symetric:
stereotypes.append(_('symetric'))
if self.symmetric:
stereotypes.append(_('symmetric'))
if self.inlined:
stereotypes.append(_('inlined'))
if self.final:
......
......@@ -168,7 +168,7 @@ partag
à la relation. Cela se limite donc aux relations dont la cardinalité
sujet->relation->objet vaut 0..1 ('?') ou 1..1 ('1')
* `symetric` : booléen indiquant que la relation est symétrique, i.e. "X relation
* `symmetric` : booléen indiquant que la relation est symétrique, i.e. "X relation
Y" implique "Y relation X"
Dans le cas de définitions de relations simultanée, `sujet` et `object` peuvent
......
......@@ -44,7 +44,7 @@ class SomeViewsTC(GAEBasedTC):
'inlined', 'inlined_relation', 'is', 'is_instance_of',
'label', 'last_login_time', 'login',
'mainvars', 'meta', 'modification_date', 'name', 'owned_by', 'pkey', 'primary_email',
'read_permission', 'require_group', 'state_of', 'surname', 'symetric',
'read_permission', 'require_group', 'state_of', 'surname', 'symmetric',
'synopsis', 'talks_about', 'title', 'to_state', 'transition_of',
'update_permission', 'use_email', 'value')))
......
......@@ -897,7 +897,7 @@ class AfterAddCWRTypeHook(DelCWRTypeHook):
description=entity.get('description'),
meta=entity.get('meta', False),
inlined=entity.get('inlined', False),
symetric=entity.get('symetric', False),
symmetric=entity.get('symmetric', False),
eid=entity.eid)
MemSchemaCWRTypeAdd(self._cw, rtype)
......@@ -919,7 +919,7 @@ class AfterUpdateCWRTypeHook(DelCWRTypeHook):
entity = self.entity
rschema = self._cw.vreg.schema.rschema(entity.name)
newvalues = {}
for prop in ('meta', 'symetric', 'inlined'):
for prop in ('meta', 'symmetric', 'inlined'):
if prop in entity:
newvalues[prop] = entity[prop]
if newvalues:
......
......@@ -302,7 +302,7 @@ class SchemaModificationHooksTC(CubicWebTC):
# schema should be update on insertion (after commit)
eeid = self.execute('INSERT CWEType X: X name "Societe2", X description "", X final FALSE')[0][0]
self._set_perms(eeid)
self.execute('INSERT CWRType X: X name "concerne2", X description "", X final FALSE, X symetric FALSE')
self.execute('INSERT CWRType X: X name "concerne2", X description "", X final FALSE, X symmetric FALSE')
self.failIf(schema.has_entity('Societe2'))
self.failIf(schema.has_entity('concerne2'))
# have to commit before adding definition relations
......
......@@ -3486,11 +3486,11 @@ msgctxt "CWUser"
msgid "surname"
msgstr ""
msgid "symetric"
msgid "symmetric"
msgstr ""
msgctxt "CWRType"
msgid "symetric"
msgid "symmetric"
msgstr ""
msgid "system entities"
......
......@@ -3585,11 +3585,11 @@ msgctxt "CWUser"
msgid "surname"
msgstr ""
msgid "symetric"
msgid "symmetric"
msgstr "simetrico"
msgctxt "CWRType"
msgid "symetric"
msgid "symmetric"
msgstr ""
msgid "system entities"
......
......@@ -3609,11 +3609,11 @@ msgctxt "CWUser"
msgid "surname"
msgstr "nom de famille"
msgid "symetric"
msgid "symmetric"
msgstr "symétrique"
msgctxt "CWRType"
msgid "symetric"
msgid "symmetric"
msgstr "symétrique"
msgid "system entities"
......
......@@ -204,7 +204,7 @@ class same_as(RelationType):
'delete': ('managers', 'owners'),
}
cardinality = '*1'
symetric = True
symmetric = True
# NOTE: the 'object = ExternalUri' declaration will still be mandatory
# in the cube's schema.
object = 'ExternalUri'
......@@ -234,7 +234,7 @@ class CWCache(EntityType):
class identical_to(RelationType):
"""identical to"""
symetric = True
symmetric = True
__permissions__ = {
'read': ('managers', 'users', 'guests',),
# XXX should have update __permissions__ on both subject and object,
......@@ -249,7 +249,7 @@ class identical_to(RelationType):
class see_also(RelationType):
"""generic relation to link one entity to another"""
symetric = True
symmetric = True
__permissions__ = {
'read': ('managers', 'users', 'guests',),
'add': ('managers', RRQLExpression('U has_update_permission S'),),
......
......@@ -33,7 +33,7 @@ class CWRType(EntityType):
unique=True, maxsize=64)
description = RichString(internationalizable=True,
description=_('semantic description of this relation type'))
symetric = Boolean(description=_('is this relation equivalent in both direction ?'))
symmetric = Boolean(description=_('is this relation equivalent in both direction ?'))
inlined = Boolean(description=_('is this relation physically inlined? you should know what you\'re doing if you are changing this!'))
fulltext_container = String(description=_('if full text content of subject/object entity '
'should be added to other side entity (the container).'),
......
......@@ -172,8 +172,8 @@ class SchemaViewer(object):
stereotypes = []
if rschema.meta:
stereotypes.append('meta')
if rschema.symetric:
stereotypes.append('symetric')
if rschema.symmetric:
stereotypes.append('symmetric')
if rschema.inlined:
stereotypes.append('inlined')
title = Section(children=(title, ' (%s)'%rschema.display_name(self.req)), klass='title')
......@@ -199,7 +199,7 @@ class SchemaViewer(object):
if (subjtype, objtype) in done:
continue
done.add((subjtype, objtype))
if rschema.symetric:
if rschema.symmetric:
done.add((objtype, subjtype))
data.append(Link(self.eschema_link_url(schema[subjtype]), subjtype))
data.append(Link(self.eschema_link_url(schema[objtype]), objtype))
......
......@@ -395,7 +395,7 @@ class ServerMigrationHelper(MigrationHelper):
current definition:
* description
* symetric, meta
* symmetric, meta
* inlined
* relation definitions if `syncrdefs`
* permissions if `syncperms`
......@@ -482,7 +482,7 @@ class ServerMigrationHelper(MigrationHelper):
if (subjtype, rschema, objtype) in self._synchronized:
return
self._synchronized.add((subjtype, rschema, objtype))
if rschema.symetric:
if rschema.symmetric:
self._synchronized.add((objtype, rschema, subjtype))
confirm = self.verbosity >= 2
if syncprops:
......@@ -764,7 +764,7 @@ class ServerMigrationHelper(MigrationHelper):
self.cmd_add_relation_type(rschema.type, False, commit=True)
rtypeadded = True
# register relation definition
# remember this two avoid adding twice non symetric relation
# remember this two avoid adding twice non symmetric relation
# such as "Emailthread forked_from Emailthread"
added.append((etype, rschema.type, targettype))
self.rqlexecall(ss.rdef2rql(rschema, etype, targettype,
......
......@@ -1129,7 +1129,7 @@ class Repository(object):
eidfrom=subject, rtype=rtype, eidto=object)
source.add_relation(session, subject, rtype, object)
rschema = self.schema.rschema(rtype)
session.update_rel_cache_add(subject, rtype, object, rschema.symetric)
session.update_rel_cache_add(subject, rtype, object, rschema.symmetric)
if source.should_call_hooks:
self.hm.call_hooks('after_add_relation', session,
eidfrom=subject, rtype=rtype, eidto=object)
......@@ -1144,9 +1144,9 @@ class Repository(object):
eidfrom=subject, rtype=rtype, eidto=object)
source.delete_relation(session, subject, rtype, object)
rschema = self.schema.rschema(rtype)
session.update_rel_cache_del(subject, rtype, object, rschema.symetric)
if rschema.symetric:
# on symetric relation, we can't now in which sense it's
session.update_rel_cache_del(subject, rtype, object, rschema.symmetric)
if rschema.symmetric:
# on symmetric relation, we can't now in which sense it's
# stored so try to delete both
source.delete_relation(session, object, rtype, subject)
if source.should_call_hooks:
......
......@@ -23,7 +23,7 @@ def _annotate_select(annotator, rqlst):
has_text_query = False
need_distinct = rqlst.distinct
for rel in rqlst.iget_nodes(Relation):
if getrschema(rel.r_type).symetric and not rel.neged(strict=True):
if getrschema(rel.r_type).symmetric and not rel.neged(strict=True):
for vref in rel.iget_nodes(VariableRef):
stinfo = vref.variable.stinfo
if not stinfo['constnode'] and stinfo['selected']:
......@@ -105,7 +105,7 @@ def _annotate_select(annotator, rqlst):
# can use N.ecrit_par as principal
if (stinfo['selected'] or len(stinfo['relations']) > 1):
break
elif rschema.symetric and stinfo['selected']:
elif rschema.symmetric and stinfo['selected']:
break
joins.add(rel)
else:
......
......@@ -113,6 +113,13 @@ def deserialize_schema(schema, session):
print sql
sqlcu.execute(sql)
# other table renaming done once schema has been read
# 3.6 migration
sqlcu.execute("SELECT * FROM cw_CWRType WHERE cw_name='symetric'")
if sqlcu.fetchall():
sql = dbhelper.sql_rename_col('cw_CWRType', 'cw_symetric', 'cw_symmetric',
dbhelper.TYPE_MAPPING['Boolean'], True)
sqlcu.execute(sql)
sqlcu.execute("UPDATE cw_CWRType SET cw_name='symmetric' WHERE cw_name='symetric'")
sidx = {}
permsdict = deserialize_ertype_permissions(session)
schema.reading_from_database = True
......@@ -163,9 +170,9 @@ def deserialize_schema(schema, session):
schema.eschema(stype)._specialized_by.append(etype)
for eid, rtype, desc, sym, il, ftc in session.execute(
'Any X,N,D,S,I,FTC WHERE X is CWRType, X name N, X description D, '
'X symetric S, X inlined I, X fulltext_container FTC', build_descr=False):
'X symmetric S, X inlined I, X fulltext_container FTC', build_descr=False):
rtype = ybo.RelationType(name=rtype, description=desc,
symetric=bool(sym), inlined=bool(il),
symmetric=bool(sym), inlined=bool(il),
fulltext_container=ftc, eid=eid)
rschema = schema.add_relation_type(rtype)
sidx[eid] = rschema
......@@ -185,7 +192,7 @@ def deserialize_schema(schema, session):
internationalizable=i18n,
default=default, eid=rdefeid)
rdefs = schema.add_relation_def(rdef)
# rdefs can be None on duplicated relation definitions (e.g. symetrics)
# rdefs can be None on duplicated relation definitions (e.g. symmetrics)
if rdefs is not None:
set_perms(rdefs, permsdict)
for values in session.execute(
......@@ -198,7 +205,7 @@ def deserialize_schema(schema, session):
cardinality=card, order=ord, description=desc,
composite=c, eid=rdefeid)
rdefs = schema.add_relation_def(rdef)
# rdefs can be None on duplicated relation definitions (e.g. symetrics)
# rdefs can be None on duplicated relation definitions (e.g. symmetrics)
if rdefs is not None:
set_perms(rdefs, permsdict)
schema.infer_specialization_rules()
......@@ -331,7 +338,7 @@ HAS_FULLTEXT_CONTAINER = True
def rschema_relations_values(rschema):
values = _ervalues(rschema)
values['final'] = rschema.final
values['symetric'] = rschema.symetric
values['symmetric'] = rschema.symmetric
values['inlined'] = rschema.inlined
if HAS_FULLTEXT_CONTAINER:
if isinstance(rschema.fulltext_container, str):
......
......@@ -133,16 +133,16 @@ class Session(RequestSessionBase):
# relations cache handling #################################################
def update_rel_cache_add(self, subject, rtype, object, symetric=False):
def update_rel_cache_add(self, subject, rtype, object, symmetric=False):
self._update_entity_rel_cache_add(subject, rtype, 'subject', object)
if symetric:
if symmetric:
self._update_entity_rel_cache_add(object, rtype, 'subject', subject)
else:
self._update_entity_rel_cache_add(object, rtype, 'object', subject)
def update_rel_cache_del(self, subject, rtype, object, symetric=False):
def update_rel_cache_del(self, subject, rtype, object, symmetric=False):
self._update_entity_rel_cache_del(subject, rtype, 'subject', object)
if symetric:
if symmetric:
self._update_entity_rel_cache_del(object, rtype, 'object', object)
else:
self._update_entity_rel_cache_del(object, rtype, 'object', subject)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment