--- a/server/repository.py Mon Apr 06 12:37:45 2009 +0200
+++ b/server/repository.py Tue Apr 07 09:30:23 2009 +0200
@@ -143,6 +143,8 @@
self.schema = CubicWebSchema(config.appid)
# querier helper, need to be created after sources initialization
self.querier = QuerierHelper(self, self.schema)
+ # should we reindex in changes?
+ self.do_fti = not config['delay-full-text-indexation']
# sources
self.sources = []
self.sources_by_uri = {}
@@ -210,7 +212,7 @@
self._get_pool().close(True)
for i in xrange(config['connections-pool-size']):
self._available_pools.put_nowait(ConnectionsPool(self.sources))
-
+
# internals ###############################################################
def get_source(self, uri, source_config):
@@ -777,7 +779,8 @@
raise UnknownEid(eid)
return extid
- def extid2eid(self, source, lid, etype, session=None, insert=True):
+ def extid2eid(self, source, lid, etype, session=None, insert=True,
+ recreate=False):
"""get eid from a local id. An eid is attributed if no record is found"""
cachekey = (str(lid), source.uri)
try:
@@ -792,6 +795,15 @@
if eid is not None:
self._extid_cache[cachekey] = eid
self._type_source_cache[eid] = (etype, source.uri, lid)
+ if recreate:
+ entity = source.before_entity_insertion(session, lid, etype, eid)
+ entity._cw_recreating = True
+ if source.should_call_hooks:
+ self.hm.call_hooks('before_add_entity', etype, session, entity)
+ # XXX add fti op ?
+ source.after_entity_insertion(session, lid, entity)
+ if source.should_call_hooks:
+ self.hm.call_hooks('after_add_entity', etype, session, entity)
if reset_pool:
session.reset_pool()
return eid
@@ -838,7 +850,8 @@
entity.complete(entity.e_schema.indexable_attributes())
session.add_query_data('neweids', entity.eid)
# now we can update the full text index
- FTIndexEntityOp(session, entity=entity)
+ if self.do_fti:
+ FTIndexEntityOp(session, entity=entity)
CleanupEidTypeCacheOp(session)
def delete_info(self, session, eid):
@@ -907,11 +920,6 @@
source = subjsource
return source
- @cached
- def rel_type_sources(self, rtype):
- return [source for source in self.sources
- if source.support_relation(rtype) or rtype in source.dont_cross_relations]
-
def locate_etype_source(self, etype):
for source in self.sources:
if source.support_entity(etype, 1):
@@ -1004,7 +1012,7 @@
entity)
source.update_entity(session, entity)
if not only_inline_rels:
- if need_fti_update:
+ if need_fti_update and self.do_fti:
# reindex the entity only if this query is updating at least
# one indexable attribute
FTIndexEntityOp(session, entity=entity)
@@ -1105,6 +1113,26 @@
pass
return nameserver
+ # multi-sources planner helpers ###########################################
+
+ @cached
+ def rel_type_sources(self, rtype):
+ return [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):
+ return [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):
+ return any(source for source in self.sources
+ if not source is self.system_source
+ and source.support_relation(rtype))
+
def pyro_unregister(config):
"""unregister the repository from the pyro name server"""