# HG changeset patch # User Sylvain Thénault # Date 1267722266 -3600 # Node ID 5642bfa432369559261d1f29893d4965495ce873 # Parent 4f12f59b1a13d5f5da9121fe88b2f1a9bf715955 [cleanup] add index_entity to abstract source, add docstring diff -r 4f12f59b1a13 -r 5642bfa43236 hooks/syncschema.py --- a/hooks/syncschema.py Thu Mar 04 18:02:33 2010 +0100 +++ b/hooks/syncschema.py Thu Mar 04 18:04:26 2010 +0100 @@ -463,17 +463,18 @@ rschema = values = None # make pylint happy def precommit_event(self): + session = self.session etype = self.kobj[0] table = SQL_PREFIX + etype column = SQL_PREFIX + self.rschema.type if 'indexed' in self.values: - sysource = self.session.pool.source('system') + sysource = session.pool.source('system') if self.values['indexed']: - sysource.create_index(self.session, table, column) + sysource.create_index(session, table, column) else: - sysource.drop_index(self.session, table, column) + sysource.drop_index(session, table, column) if 'cardinality' in self.values and self.rschema.final: - adbh = self.session.pool.source('system').dbhelper + adbh = session.pool.source('system').dbhelper if not adbh.alter_column_support: # not supported (and NOT NULL not set by yams in that case, so # no worry) @@ -485,11 +486,17 @@ # XXX check self.values['cardinality'][0] actually changed? sql = adbh.sql_set_null_allowed(table, column, coltype, self.values['cardinality'][0] != '1') - self.session.system_sql(sql) + session.system_sql(sql) if 'fulltextindexed' in self.values: - UpdateFTIndexOp(self.session) - self.session.transaction_data.setdefault('fti_update_etypes', - set()).add(etype) + UpdateFTIndexOp(session) + session.transaction_data.setdefault( + 'fti_update_etypes', set()).add(etype) + elif 'fulltext_container' in self.values: + ftiupdates = session.transaction_data.setdefault( + 'fti_update_etypes', set()) + ftiupdates.add(etype) + ftiupdates.add(self.kobj[1]) + UpdateFTIndexOp(session) class SourceDbCWConstraintAdd(hook.Operation): diff -r 4f12f59b1a13 -r 5642bfa43236 server/sources/__init__.py --- a/server/sources/__init__.py Thu Mar 04 18:02:33 2010 +0100 +++ b/server/sources/__init__.py Thu Mar 04 18:04:26 2010 +0100 @@ -382,6 +382,22 @@ """ raise NotImplementedError() + def modified_entities(self, session, etypes, mtime): + """return a 2-uple: + * list of (etype, eid) of entities of the given types which have been + modified since the given timestamp (actually entities whose full text + index content has changed) + * list of (etype, eid) of entities of the given types which have been + deleted since the given timestamp + """ + raise NotImplementedError() + + def index_entity(self, session, entity): + """create an operation to [re]index textual content of the given entity + on commit + """ + raise NotImplementedError() + def fti_unindex_entity(self, session, eid): """remove text content for entity with the given eid from the full text index @@ -393,16 +409,6 @@ """ raise NotImplementedError() - def modified_entities(self, session, etypes, mtime): - """return a 2-uple: - * list of (etype, eid) of entities of the given types which have been - modified since the given timestamp (actually entities whose full text - index content has changed) - * list of (etype, eid) of entities of the given types which have been - deleted since the given timestamp - """ - raise NotImplementedError() - # sql system source interface ############################################# def sqlexec(self, session, sql, args=None): diff -r 4f12f59b1a13 -r 5642bfa43236 server/sources/native.py --- a/server/sources/native.py Thu Mar 04 18:02:33 2010 +0100 +++ b/server/sources/native.py Thu Mar 04 18:04:26 2010 +0100 @@ -596,6 +596,9 @@ return False def index_entity(self, session, entity): + """create an operation to [re]index textual content of the given entity + on commit + """ FTIndexEntityOp(session, entity=entity) def fti_unindex_entity(self, session, eid):