28 from yams import BadSchemaDefinition |
28 from yams import BadSchemaDefinition |
29 from rql import RQLSyntaxError |
29 from rql import RQLSyntaxError |
30 |
30 |
31 from cubicweb import (CW_SOFTWARE_ROOT, CW_MIGRATION_MAP, CW_EVENT_MANAGER, |
31 from cubicweb import (CW_SOFTWARE_ROOT, CW_MIGRATION_MAP, CW_EVENT_MANAGER, |
32 UnknownEid, AuthenticationError, ExecutionError, |
32 UnknownEid, AuthenticationError, ExecutionError, |
33 ETypeNotSupportedBySources, RTypeNotSupportedBySources, |
33 ETypeNotSupportedBySources, MultiSourcesError, |
34 BadConnectionId, Unauthorized, ValidationError, |
34 BadConnectionId, Unauthorized, ValidationError, |
35 typed_eid) |
35 typed_eid) |
36 from cubicweb import cwvreg, schema, server |
36 from cubicweb import cwvreg, schema, server |
37 from cubicweb.server import utils, hook, pool, querier, sources |
37 from cubicweb.server import utils, hook, pool, querier, sources |
38 from cubicweb.server.session import Session, InternalSession |
38 from cubicweb.server.session import Session, InternalSession |
925 self.system_source.fti_index_entity(session, entity) |
925 self.system_source.fti_index_entity(session, entity) |
926 |
926 |
927 def locate_relation_source(self, session, subject, rtype, object): |
927 def locate_relation_source(self, session, subject, rtype, object): |
928 subjsource = self.source_from_eid(subject, session) |
928 subjsource = self.source_from_eid(subject, session) |
929 objsource = self.source_from_eid(object, session) |
929 objsource = self.source_from_eid(object, session) |
930 if not (subjsource is objsource and subjsource.support_relation(rtype, 1)): |
930 if not subjsource is objsource: |
931 source = self.system_source |
931 source = self.system_source |
932 if not source.support_relation(rtype, 1): |
932 if not (subjsource.may_cross_relation(rtype) |
933 raise RTypeNotSupportedBySources(rtype) |
933 and objsource.may_cross_relation(rtype)): |
|
934 raise MultiSourcesError( |
|
935 "relation %s can't be crossed among sources" |
|
936 % rtype) |
|
937 elif not subjsource.support_relation(rtype): |
|
938 source = self.system_source |
934 else: |
939 else: |
935 source = subjsource |
940 source = subjsource |
|
941 if not source.support_relation(rtype, True): |
|
942 raise MultiSourcesError( |
|
943 "source %s doesn't support write of %s relation" |
|
944 % (source.uri, rtype)) |
936 return source |
945 return source |
937 |
946 |
938 def locate_etype_source(self, etype): |
947 def locate_etype_source(self, etype): |
939 for source in self.sources: |
948 for source in self.sources: |
940 if source.support_entity(etype, 1): |
949 if source.support_entity(etype, 1): |