diff -r bab2befaac9b -r d9a1e7939ee6 server/migractions.py --- a/server/migractions.py Fri Jun 13 12:07:51 2014 +0200 +++ b/server/migractions.py Fri Jun 13 13:54:28 2014 +0200 @@ -125,6 +125,8 @@ self.fs_schema = schema self._synchronized = set() + # overriden from base MigrationHelper ###################################### + def set_cnx(self): try: login = self.repo.config.default_admin_config['login'] @@ -150,7 +152,6 @@ sys.exit(0) self.session = self.repo._get_session(self.cnx.sessionid) - # overriden from base MigrationHelper ###################################### @cached def repo_connect(self): @@ -177,7 +178,7 @@ super(ServerMigrationHelper, self).migrate(vcconf, toupgrade, options) def cmd_process_script(self, migrscript, funcname=None, *args, **kwargs): - with self.cnx._cnx.ensure_cnx_set: + with self.cnx.ensure_cnx_set: try: return super(ServerMigrationHelper, self).cmd_process_script( migrscript, funcname, *args, **kwargs) @@ -286,12 +287,10 @@ print '-> database restored.' def commit(self): - if hasattr(self, 'cnx'): - self.cnx.commit(free_cnxset=False) + self.cnx.commit() def rollback(self): - if hasattr(self, 'cnx'): - self.cnx.rollback(free_cnxset=False) + self.cnx.rollback() def rqlexecall(self, rqliter, ask_confirm=False): for rql, kwargs in rqliter: @@ -309,7 +308,7 @@ 'schema': self.repo.get_schema(), 'cnx': self.cnx, 'fsschema': self.fs_schema, - 'session' : self.cnx._cnx, + 'session' : self.cnx, 'repo' : self.repo, }) return context @@ -957,7 +956,6 @@ % (rtype, new.eid, oldeid), ask_confirm=False) # delete relations using SQL to avoid relations content removal # triggered by schema synchronization hooks. - session = self.session for rdeftype in ('CWRelation', 'CWAttribute'): thispending = set( (eid for eid, in self.sqlexec( 'SELECT cw_eid FROM cw_%s WHERE cw_from_entity=%%(eid)s OR ' @@ -967,10 +965,10 @@ # get some validation error on commit since integrity hooks # may think some required relation is missing... This also ensure # repository caches are properly cleanup - hook.CleanupDeletedEidsCacheOp.get_instance(session).union(thispending) + hook.CleanupDeletedEidsCacheOp.get_instance(self.cnx).union(thispending) # and don't forget to remove record from system tables entities = [self.cnx.entity_from_eid(eid, rdeftype) for eid in thispending] - self.repo.system_source.delete_info_multi(self.cnx._cnx, entities) + self.repo.system_source.delete_info_multi(self.cnx, entities) self.sqlexec('DELETE FROM cw_%s WHERE cw_from_entity=%%(eid)s OR ' 'cw_to_entity=%%(eid)s' % rdeftype, {'eid': oldeid}, ask_confirm=False) @@ -1391,7 +1389,7 @@ indexable entity types """ from cubicweb.server.checkintegrity import reindex_entities - reindex_entities(self.repo.schema, self.cnx._cnx, etypes=etypes) + reindex_entities(self.repo.schema, self.cnx, etypes=etypes) @contextmanager def cmd_dropped_constraints(self, etype, attrname, cstrtype=None, @@ -1490,7 +1488,7 @@ self.sqlexec(sql, ask_confirm=False) dbhelper = self.repo.system_source.dbhelper sqltype = dbhelper.TYPE_MAPPING[newtype] - cursor = self.cnx._cnx.cnxset.cu + cursor = self.cnx.cnxset.cu dbhelper.change_col_type(cursor, 'cw_%s' % etype, 'cw_%s' % attr, sqltype, allownull) if commit: self.commit()