server/sources/native.py
changeset 9466 c3a5f4507f12
parent 9465 86d4b41ae339
child 9467 ad66d7b3fd48
equal deleted inserted replaced
9465:86d4b41ae339 9466:c3a5f4507f12
    57 from cubicweb.utils import QueryCache
    57 from cubicweb.utils import QueryCache
    58 from cubicweb.schema import VIRTUAL_RTYPES
    58 from cubicweb.schema import VIRTUAL_RTYPES
    59 from cubicweb.cwconfig import CubicWebNoAppConfiguration
    59 from cubicweb.cwconfig import CubicWebNoAppConfiguration
    60 from cubicweb.server import hook
    60 from cubicweb.server import hook
    61 from cubicweb.server.utils import crypt_password, eschema_eid, verify_and_update
    61 from cubicweb.server.utils import crypt_password, eschema_eid, verify_and_update
    62 from cubicweb.server.sqlutils import SQL_PREFIX, SQLAdapterMixIn, SqliteCnxLoggingWrapper
    62 from cubicweb.server.sqlutils import SQL_PREFIX, SQLAdapterMixIn
    63 from cubicweb.server.rqlannotation import set_qdata
    63 from cubicweb.server.rqlannotation import set_qdata
    64 from cubicweb.server.hook import CleanupDeletedEidsCacheOp
    64 from cubicweb.server.hook import CleanupDeletedEidsCacheOp
    65 from cubicweb.server.edition import EditedEntity
    65 from cubicweb.server.edition import EditedEntity
    66 from cubicweb.server.sources import AbstractSource, dbg_st_search, dbg_results
    66 from cubicweb.server.sources import AbstractSource, dbg_st_search, dbg_results
    67 from cubicweb.server.sources.rql2sql import SQLGenerator
    67 from cubicweb.server.sources.rql2sql import SQLGenerator
   285         # explain)
   285         # explain)
   286         self._eid_cnx_lock = Lock()
   286         self._eid_cnx_lock = Lock()
   287         self._eid_creation_cnx = None
   287         self._eid_creation_cnx = None
   288         # (etype, attr) / storage mapping
   288         # (etype, attr) / storage mapping
   289         self._storages = {}
   289         self._storages = {}
   290         # XXX no_sqlite_wrap trick since we've a sqlite locking pb when
       
   291         # running unittest_multisources with the wrapping below
       
   292         if self.dbdriver == 'sqlite' and \
       
   293                not getattr(repo.config, 'no_sqlite_wrap', False):
       
   294             from cubicweb.server.pool import ConnectionsSet
       
   295             self.dbhelper.dbname = abspath(self.dbhelper.dbname)
       
   296             self.get_connection = lambda: SqliteCnxLoggingWrapper(self)
       
   297             self.check_connection = lambda cnx: cnx
       
   298             def cnxset_freed(self):
       
   299                 self.cnx.close()
       
   300             ConnectionsSet.cnxset_freed = cnxset_freed
       
   301         if self.dbdriver == 'sqlite':
   290         if self.dbdriver == 'sqlite':
   302             self._create_eid = None
   291             self._create_eid = None
   303             self.create_eid = self._create_eid_sqlite
   292             self.create_eid = self._create_eid_sqlite
   304         self.binary_to_str = self.dbhelper.dbapi_module.binary_to_str
   293         self.binary_to_str = self.dbhelper.dbapi_module.binary_to_str
   305 
   294 
   332     def init_creating(self, cnxset=None):
   321     def init_creating(self, cnxset=None):
   333         # check full text index availibility
   322         # check full text index availibility
   334         if self.do_fti:
   323         if self.do_fti:
   335             if cnxset is None:
   324             if cnxset is None:
   336                 _cnxset = self.repo._get_cnxset()
   325                 _cnxset = self.repo._get_cnxset()
   337                 _cnxset.cnxset_set()
       
   338             else:
   326             else:
   339                 _cnxset = cnxset
   327                 _cnxset = cnxset
   340             if not self.dbhelper.has_fti_table(_cnxset.cu):
   328             if not self.dbhelper.has_fti_table(_cnxset.cu):
   341                 if not self.repo.config.creating:
   329                 if not self.repo.config.creating:
   342                     self.critical('no text index table')
   330                     self.critical('no text index table')
  1597             raise AuthenticationError('unexisting email')
  1585             raise AuthenticationError('unexisting email')
  1598         login = rset.rows[0][0]
  1586         login = rset.rows[0][0]
  1599         authinfo['email_auth'] = True
  1587         authinfo['email_auth'] = True
  1600         return self.source.repo.check_auth_info(session, login, authinfo)
  1588         return self.source.repo.check_auth_info(session, login, authinfo)
  1601 
  1589 
       
  1590 
  1602 class DatabaseIndependentBackupRestore(object):
  1591 class DatabaseIndependentBackupRestore(object):
  1603     """Helper class to perform db backend agnostic backup and restore
  1592     """Helper class to perform db backend agnostic backup and restore
  1604 
  1593 
  1605     The backup and restore methods are used to dump / restore the
  1594     The backup and restore methods are used to dump / restore the
  1606     system database in a database independent format. The file is a
  1595     system database in a database independent format. The file is a