dataimport.py
changeset 7398 26695dd703d8
parent 7227 23d9c1f89c96
child 7471 bf9443f8725f
equal deleted inserted replaced
7397:6a9e66d788b3 7398:26695dd703d8
   443 
   443 
   444     def __init__(self, session=None, commit=None):
   444     def __init__(self, session=None, commit=None):
   445         ObjectStore.__init__(self)
   445         ObjectStore.__init__(self)
   446         if session is None:
   446         if session is None:
   447             sys.exit('please provide a session of run this script with cubicweb-ctl shell and pass cnx as session')
   447             sys.exit('please provide a session of run this script with cubicweb-ctl shell and pass cnx as session')
   448         if not hasattr(session, 'set_pool'):
   448         if not hasattr(session, 'set_cnxset'):
   449             # connection
   449             # connection
   450             cnx = session
   450             cnx = session
   451             session = session.request()
   451             session = session.request()
   452             session.set_pool = lambda : None
   452             session.set_cnxset = lambda : None
   453             commit = commit or cnx.commit
   453             commit = commit or cnx.commit
   454         else:
   454         else:
   455             session.set_pool()
   455             session.set_cnxset()
   456         self.session = session
   456         self.session = session
   457         self._commit = commit or session.commit
   457         self._commit = commit or session.commit
   458 
   458 
   459     @deprecated("[3.7] checkpoint() deprecated. use commit() instead")
   459     @deprecated("[3.7] checkpoint() deprecated. use commit() instead")
   460     def checkpoint(self):
   460     def checkpoint(self):
   461         self.commit()
   461         self.commit()
   462 
   462 
   463     def commit(self):
   463     def commit(self):
   464         txuuid = self._commit()
   464         txuuid = self._commit()
   465         self.session.set_pool()
   465         self.session.set_cnxset()
   466         return txuuid
   466         return txuuid
   467 
   467 
   468     def rql(self, *args):
   468     def rql(self, *args):
   469         if self._rql is not None:
   469         if self._rql is not None:
   470             return self._rql(*args)
   470             return self._rql(*args)