# HG changeset patch # User Sylvain Thénault # Date 1269862121 -7200 # Node ID 1d5c81588144ea7f399f0d63f0249a8b159a6922 # Parent 6dfeb8e75188190b4ed8b33df4265c366525a080 [repo] make etype which should go in deleted_entities configurable: we only need this for types imported from other multi-sources instances diff -r 6dfeb8e75188 -r 1d5c81588144 server/serverconfig.py --- a/server/serverconfig.py Mon Mar 29 13:26:20 2010 +0200 +++ b/server/serverconfig.py Mon Mar 29 13:28:41 2010 +0200 @@ -141,6 +141,14 @@ kept (hence undoable).', 'group': 'main', 'inputlevel': 1, }), + ('multi-sources-etypes', + {'type' : 'csv', 'default': (), + 'help': 'defines which entity types from this repository are used \ +by some other instances. You should set this properly so those instances to \ +detect updates / deletions.', + 'group': 'main', 'inputlevel': 1, + }), + ('delay-full-text-indexation', {'type' : 'yn', 'default': False, 'help': 'When full text indexation of entity has a too important cost' diff -r 6dfeb8e75188 -r 1d5c81588144 server/sources/native.py --- a/server/sources/native.py Mon Mar 29 13:26:20 2010 +0200 +++ b/server/sources/native.py Mon Mar 29 13:28:41 2010 +0200 @@ -194,6 +194,8 @@ self._eid_creation_lock = Lock() # (etype, attr) / storage mapping self._storages = {} + # entity types that may be used by other multi-sources instances + self.multisources_etypes = set(repo.config['multi-sources-etypes']) # XXX no_sqlite_wrap trick since we've a sqlite locking pb when # running unittest_multisources with the wrapping below if self.dbdriver == 'sqlite' and \ @@ -659,16 +661,21 @@ # reindex the entity only if this query is updating at least # one indexable attribute FTIndexEntityOp(session, entity=entity) - # update entities.mtime + # update entities.mtime. + # XXX Only if entity.__regid__ in self.multisources_etypes? attrs = {'eid': entity.eid, 'mtime': datetime.now()} self.doexec(session, self.sqlgen.update('entities', attrs, ['eid']), attrs) def delete_info(self, session, entity, uri, extid): - """delete system information on deletion of an entity by transfering - record from the entities table to the deleted_entities table + """delete system information on deletion of an entity: + * remove record from the entities table + * transfer it to the deleted_entities table if the entity's type is + multi-sources """ attrs = {'eid': entity.eid} self.doexec(session, self.sqlgen.delete('entities', attrs), attrs) + if not entity.__regid__ in self.multisources_etypes: + return if extid is not None: assert isinstance(extid, str), type(extid) extid = b64encode(extid) @@ -685,6 +692,11 @@ * list of (etype, eid) of entities of the given types which have been deleted since the given timestamp """ + for etype in etypes: + if not etype in self.multisources_etypes: + self.critical('%s not listed as a multi-sources entity types. ' + 'Modify your configuration') + self.multisources_etypes.add(etype) modsql = _modified_sql('entities', etypes) cursor = self.doexec(session, modsql, {'time': mtime}) modentities = cursor.fetchall() @@ -931,8 +943,10 @@ self.doexec(session, sql, action.changes) # restore record in entities (will update fti if needed) self.add_info(session, entity, self, None, True) - # remove record from deleted_entities - self.doexec(session, 'DELETE FROM deleted_entities WHERE eid=%s' % eid) + # remove record from deleted_entities if entity's type is multi-sources + if entity.__regid__ in self.multisources_etypes: + self.doexec(session, + 'DELETE FROM deleted_entities WHERE eid=%s' % eid) self.repo.hm.call_hooks('after_add_entity', session, entity=entity) return errors