server/sources/native.py
changeset 2493 9806571ea790
parent 2476 1294a6bdf3bf
child 2589 92f2bc945261
equal deleted inserted replaced
2492:c51be1cf8317 2493:9806571ea790
    23 
    23 
    24 from indexer import get_indexer
    24 from indexer import get_indexer
    25 
    25 
    26 from cubicweb import UnknownEid, AuthenticationError, Binary, server
    26 from cubicweb import UnknownEid, AuthenticationError, Binary, server
    27 from cubicweb.server.utils import crypt_password
    27 from cubicweb.server.utils import crypt_password
    28 from cubicweb.server.sqlutils import SQL_PREFIX, SQLAdapterMixIn
    28 from cubicweb.server.sqlutils import (SQL_PREFIX, SQLAdapterMixIn,
       
    29                                       sql_source_backup, sql_source_restore)
    29 from cubicweb.server.rqlannotation import set_qdata
    30 from cubicweb.server.rqlannotation import set_qdata
    30 from cubicweb.server.sources import AbstractSource
    31 from cubicweb.server.sources import AbstractSource
    31 from cubicweb.server.sources.rql2sql import SQLGenerator
    32 from cubicweb.server.sources.rql2sql import SQLGenerator
    32 
    33 
    33 
    34 
   197             self.error('no text index table')
   198             self.error('no text index table')
   198             self.indexer = None
   199             self.indexer = None
   199         pool.pool_reset()
   200         pool.pool_reset()
   200         self.repo._free_pool(pool)
   201         self.repo._free_pool(pool)
   201 
   202 
       
   203     def backup(self, confirm, backupfile=None, timestamp=None,
       
   204                askconfirm=False):
       
   205         """method called to create a backup of source's data"""
       
   206         backupfile = self.backup_file(backupfile, timestamp)
       
   207         sql_source_backup(self, self, confirm, backupfile, askconfirm)
       
   208 
       
   209     def restore(self, confirm, backupfile=None, timestamp=None, drop=True,
       
   210                askconfirm=False):
       
   211         """method called to restore a backup of source's data"""
       
   212         backupfile = self.backup_file(backupfile, timestamp)
       
   213         sql_source_restore(self, self, confirm, backupfile, drop, askconfirm)
       
   214 
   202     def init(self):
   215     def init(self):
   203         self.init_creating()
   216         self.init_creating()
   204         pool = self.repo._get_pool()
   217         pool = self.repo._get_pool()
   205         pool.pool_set()
   218         pool.pool_set()
   206         # XXX cubicweb < 2.42 compat
   219         # XXX cubicweb < 2.42 compat
   211         pool.pool_reset()
   224         pool.pool_reset()
   212         self.repo._free_pool(pool)
   225         self.repo._free_pool(pool)
   213 
   226 
   214     def map_attribute(self, etype, attr, cb):
   227     def map_attribute(self, etype, attr, cb):
   215         self._rql_sqlgen.attr_map['%s.%s' % (etype, attr)] = cb
   228         self._rql_sqlgen.attr_map['%s.%s' % (etype, attr)] = cb
   216         
   229 
   217     # ISource interface #######################################################
   230     # ISource interface #######################################################
   218 
   231 
   219     def compile_rql(self, rql):
   232     def compile_rql(self, rql):
   220         rqlst = self.repo.querier._rqlhelper.parse(rql)
   233         rqlst = self.repo.querier._rqlhelper.parse(rql)
   221         rqlst.restricted_vars = ()
   234         rqlst.restricted_vars = ()