--- a/_exceptions.py Thu Aug 27 17:02:02 2009 +0200
+++ b/_exceptions.py Thu Aug 27 17:03:19 2009 +0200
@@ -65,9 +65,8 @@
"""no source support an entity type"""
msg = 'No source supports %r entity\'s type'
-class RTypeNotSupportedBySources(RepositoryError, InternalError):
- """no source support a relation type"""
- msg = 'No source supports %r relation\'s type'
+class MultiSourcesError(RepositoryError, InternalError):
+ """usually due to bad multisources configuration or rql query"""
# security exceptions #########################################################
--- a/server/repository.py Thu Aug 27 17:02:02 2009 +0200
+++ b/server/repository.py Thu Aug 27 17:03:19 2009 +0200
@@ -30,7 +30,7 @@
from cubicweb import (CW_SOFTWARE_ROOT, CW_MIGRATION_MAP, CW_EVENT_MANAGER,
UnknownEid, AuthenticationError, ExecutionError,
- ETypeNotSupportedBySources, RTypeNotSupportedBySources,
+ ETypeNotSupportedBySources, MultiSourcesError,
BadConnectionId, Unauthorized, ValidationError,
typed_eid)
from cubicweb.cwvreg import CubicWebVRegistry
@@ -972,12 +972,21 @@
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 and subjsource.support_relation(rtype, 1)):
+ if not subjsource is objsource:
source = self.system_source
- if not source.support_relation(rtype, 1):
- raise RTypeNotSupportedBySources(rtype)
+ 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):
+ source = self.system_source
else:
source = subjsource
+ if not source.support_relation(rtype, True):
+ raise MultiSourcesError(
+ "source %s doesn't support write of %s relation"
+ % (source.uri, rtype))
return source
def locate_etype_source(self, etype):