# HG changeset patch # User Sylvain Thénault # Date 1390382370 -3600 # Node ID 5308b3fe03c90e5835b01ffcc524ed803ee52458 # Parent c83a8ecb9bf5f9fb35bfa0ffd286a008a41461b6 [multi-sources-removal] Drop (dont_)cross relation related code That was only needed for now deleted 'true' multisources. Related to #2919300 [jcr: also remove it from server/test/data-schemaserial/schema.py] diff -r c83a8ecb9bf5 -r 5308b3fe03c9 devtools/repotest.py --- a/devtools/repotest.py Mon Jun 17 00:15:51 2013 +0200 +++ b/devtools/repotest.py Wed Jan 22 10:19:30 2014 +0100 @@ -280,9 +280,6 @@ newsources = () def setup(self): - clear_cache(self.repo, 'rel_type_sources') - clear_cache(self.repo, 'rel_type_sources') - clear_cache(self.repo, 'can_cross_relation') clear_cache(self.repo, 'is_multi_sources_relation') # XXX source_defs self.o = self.repo.querier diff -r c83a8ecb9bf5 -r 5308b3fe03c9 server/repository.py --- a/server/repository.py Mon Jun 17 00:15:51 2013 +0200 +++ b/server/repository.py Wed Jan 22 10:19:30 2014 +0100 @@ -286,8 +286,7 @@ self.add_source(sourceent) def _clear_planning_caches(self): - for cache in ('source_defs', 'is_multi_sources_relation', - 'can_cross_relation', 'rel_type_sources'): + for cache in ('source_defs', 'is_multi_sources_relation'): clear_cache(self, cache) def add_source(self, sourceent): @@ -1163,13 +1162,6 @@ else: rql = 'DELETE Y %s X WHERE X eid %%(x)s' % rtype if scleanup is not None: - # if the relation can't be crossed, nothing to cleanup (we - # would get a BadRQLQuery from the multi-sources planner). - # This may still leave some junk if the mapping has changed - # at some point, but one can still run db-check to catch - # those - if not source in self.can_cross_relation(rtype): - continue # source cleaning: only delete relations stored locally # (here, scleanup rql += ', NOT (Y cw_source S, S eid %(seid)s)' @@ -1205,13 +1197,6 @@ else: rql = 'DELETE Y %s X WHERE X eid IN (%s)' % (rtype, in_eids) if scleanup is not None: - # if the relation can't be crossed, nothing to cleanup (we - # would get a BadRQLQuery from the multi-sources planner). - # This may still leave some junk if the mapping has changed - # at some point, but one can still run db-check to catch - # those - if not source in self.can_cross_relation(rtype): - continue # source cleaning: only delete relations stored locally rql += ', NOT (Y cw_source S, S eid %(seid)s)' try: @@ -1233,14 +1218,7 @@ def locate_relation_source(self, session, subject, rtype, object): subjsource = self.source_from_eid(subject, session) objsource = self.source_from_eid(object, session) - if not subjsource is objsource: - source = self.system_source - if not (subjsource.may_cross_relation(rtype) - and objsource.may_cross_relation(rtype)): - raise MultiSourcesError( - "relation %s can't be crossed among sources" - % rtype) - elif not subjsource.support_relation(rtype): + if not subjsource.support_relation(rtype): source = self.system_source else: source = subjsource @@ -1590,22 +1568,6 @@ # multi-sources planner helpers ########################################### @cached - def rel_type_sources(self, rtype): - warn('[3.18] old multi-source system will go away in the next version', - DeprecationWarning) - return tuple([source for source in self.sources - if source.support_relation(rtype) - or rtype in source.dont_cross_relations]) - - @cached - def can_cross_relation(self, rtype): - warn('[3.18] old multi-source system will go away in the next version', - DeprecationWarning) - return tuple([source for source in self.sources - if source.support_relation(rtype) - and rtype in source.cross_relations]) - - @cached def is_multi_sources_relation(self, rtype): warn('[3.18] old multi-source system will go away in the next version', DeprecationWarning) diff -r c83a8ecb9bf5 -r 5308b3fe03c9 server/sources/__init__.py --- a/server/sources/__init__.py Mon Jun 17 00:15:51 2013 +0200 +++ b/server/sources/__init__.py Wed Jan 22 10:19:30 2014 +0100 @@ -85,10 +85,6 @@ # a reference to the instance'schema (may differs from the source'schema) schema = None - # multi-sources planning control - dont_cross_relations = () - cross_relations = () - # force deactivation (configuration error for instance) disabled = False @@ -310,22 +306,6 @@ return wsupport return True - def may_cross_relation(self, rtype): - """return True if the relation may be crossed among sources. Rules are: - - * if this source support the relation, can't be crossed unless explicitly - specified in .cross_relations - - * if this source doesn't support the relation, can be crossed unless - explicitly specified in .dont_cross_relations - """ - # XXX find a way to have relation such as state_of in dont cross - # relation (eg composite relation without both end type available? - # card 1 relation ? ...) - if self.support_relation(rtype): - return rtype in self.cross_relations - return rtype not in self.dont_cross_relations - def before_entity_insertion(self, session, lid, etype, eid, sourceparams): """called by the repository when an eid has been attributed for an entity stored here but the entity has not been inserted in the system diff -r c83a8ecb9bf5 -r 5308b3fe03c9 server/sources/native.py --- a/server/sources/native.py Mon Jun 17 00:15:51 2013 +0200 +++ b/server/sources/native.py Wed Jan 22 10:19:30 2014 +0100 @@ -468,9 +468,6 @@ # can't claim not supporting a relation return True #not rtype == 'content_for' - def may_cross_relation(self, rtype): - return True - def authenticate(self, session, login, **kwargs): """return CWUser eid for the given login and other authentication information found in kwargs, else raise `AuthenticationError` diff -r c83a8ecb9bf5 -r 5308b3fe03c9 server/test/data-schemaserial/schema.py --- a/server/test/data-schemaserial/schema.py Mon Jun 17 00:15:51 2013 +0200 +++ b/server/test/data-schemaserial/schema.py Wed Jan 22 10:19:30 2014 +0100 @@ -168,20 +168,6 @@ object = 'Card' cardinality = '??' -class multisource_inlined_rel(RelationDefinition): - inlined = True - cardinality = '?*' - subject = ('Card', 'Note') - object = ('Affaire', 'Note') - -class multisource_rel(RelationDefinition): - subject = ('Card', 'Note') - object = 'Note' - -class multisource_crossed_rel(RelationDefinition): - subject = ('Card', 'Note') - object = 'Note' - class see_also_1(RelationDefinition): name = 'see_also' diff -r c83a8ecb9bf5 -r 5308b3fe03c9 server/test/data/schema.py --- a/server/test/data/schema.py Mon Jun 17 00:15:51 2013 +0200 +++ b/server/test/data/schema.py Wed Jan 22 10:19:30 2014 +0100 @@ -174,14 +174,6 @@ subject = ('Card', 'Note') object = ('Affaire', 'Note') -class multisource_rel(RelationDefinition): - subject = ('Card', 'Note') - object = 'Note' - -class multisource_crossed_rel(RelationDefinition): - subject = ('Card', 'Note') - object = 'Note' - class see_also_1(RelationDefinition): name = 'see_also' diff -r c83a8ecb9bf5 -r 5308b3fe03c9 web/views/cwsources.py --- a/web/views/cwsources.py Mon Jun 17 00:15:51 2013 +0200 +++ b/web/views/cwsources.py Wed Jan 22 10:19:30 2014 +0100 @@ -117,20 +117,6 @@ 'Any X, SCH, XO ORDERBY ET WHERE X options XO, X cw_for_source S, S eid %(s)s, ' 'X cw_schema SCH, SCH is ET', {'s': entity.eid}) self.wview('table', rset, 'noresult') - # self.w('

%s

' % _('Relations that should not be crossed')) - # self.w('

%s

' % _( - # 'By default, when a relation is not supported by a source, it is ' - # 'supposed that a local relation may point to an entity from the ' - # 'external source. Relations listed here won\'t have this ' - # '"crossing" behaviour.')) - # self.wview('list', entity.related('cw_dont_cross'), 'noresult') - # self.w('

%s

' % _('Relations that can be crossed')) - # self.w('

%s

' % _( - # 'By default, when a relation is supported by a source, it is ' - # 'supposed that a local relation can\'t point to an entity from the ' - # 'external source. Relations listed here may have this ' - # '"crossing" behaviour anyway.')) - # self.wview('list', entity.related('cw_may_cross'), 'noresult') checker = MAPPING_CHECKERS.get(entity.type, MappingChecker)(entity) checker.check() if (checker.errors or checker.warnings or checker.infos):