Komutlar veritabanına yazma işlemi yapmayacağım diyebilsin.
Eskisi gibi aksi söylenmedikçe, hepsi yazacak şekilde açsın.
This commit is contained in:
@@ -137,12 +137,12 @@ class Command(object):
|
|||||||
else:
|
else:
|
||||||
self.authInfo = None
|
self.authInfo = None
|
||||||
|
|
||||||
def init(self, database = True):
|
def init(self, database = True, write = True):
|
||||||
"""initialize PiSi components"""
|
"""initialize PiSi components"""
|
||||||
|
|
||||||
# NB: command imports here or in the command class run fxns
|
# NB: command imports here or in the command class run fxns
|
||||||
import pisi.api
|
import pisi.api
|
||||||
pisi.api.init(database = database, options = self.options,
|
pisi.api.init(database = database, write = write, options = self.options,
|
||||||
comar = self.comar)
|
comar = self.comar)
|
||||||
|
|
||||||
def finalize(self):
|
def finalize(self):
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ def init_dbenv(write=False, writeversion=False):
|
|||||||
check_dbversion('filesdbversion', pisi.__filesdbversion__, write=write, update=writeversion)
|
check_dbversion('filesdbversion', pisi.__filesdbversion__, write=write, update=writeversion)
|
||||||
else:
|
else:
|
||||||
raise Error(_('Cannot attain read access to database environment'))
|
raise Error(_('Cannot attain read access to database environment'))
|
||||||
if os.access(pisi.context.config.db_dir(), os.W_OK):
|
if write and os.access(pisi.context.config.db_dir(), os.W_OK):
|
||||||
ctx.dbenv = dbobj.DBEnv()
|
ctx.dbenv = dbobj.DBEnv()
|
||||||
flags = (db.DB_INIT_MPOOL | # cache
|
flags = (db.DB_INIT_MPOOL | # cache
|
||||||
db.DB_INIT_TXN | # transaction subsystem
|
db.DB_INIT_TXN | # transaction subsystem
|
||||||
@@ -87,7 +87,9 @@ def init_dbenv(write=False, writeversion=False):
|
|||||||
ctx.dbenv.open(pisi.context.config.db_dir(), flags)
|
ctx.dbenv.open(pisi.context.config.db_dir(), flags)
|
||||||
ctx.dbenv.set_flags(db.DB_LOG_AUTOREMOVE, 1) # clear inactive logs automatically
|
ctx.dbenv.set_flags(db.DB_LOG_AUTOREMOVE, 1) # clear inactive logs automatically
|
||||||
else:
|
else:
|
||||||
ctx.ui.warning(_("Opening PISI database in read-only mode. Operations that require write access will fail."))
|
# Warn if not on purpose
|
||||||
|
if write:
|
||||||
|
ctx.ui.warning(_("Opening PISI database in read-only mode. Operations that require write access will fail."))
|
||||||
ctx.dbenv = None
|
ctx.dbenv = None
|
||||||
|
|
||||||
#def open(filename, flags='r', mode = 0644, filetype = db.DB_BTREE):
|
#def open(filename, flags='r', mode = 0644, filetype = db.DB_BTREE):
|
||||||
@@ -113,10 +115,8 @@ class LockedDBShelf(shelve.DBShelf):
|
|||||||
dbenv = ctx.dbenv
|
dbenv = ctx.dbenv
|
||||||
shelve.DBShelf.__init__(self, dbenv)
|
shelve.DBShelf.__init__(self, dbenv)
|
||||||
filename = join_path(pisi.context.config.db_dir(), dbname + '.bdb')
|
filename = join_path(pisi.context.config.db_dir(), dbname + '.bdb')
|
||||||
if os.access(os.path.dirname(filename), os.W_OK):
|
if dbenv and os.access(os.path.dirname(filename), os.W_OK):
|
||||||
flags = 'w'
|
flags = 'w'
|
||||||
if not self.dbenv:
|
|
||||||
raise Error(_('Database writes not allowed without transactions'))
|
|
||||||
elif os.access(filename, os.R_OK):
|
elif os.access(filename, os.R_OK):
|
||||||
flags = 'r'
|
flags = 'r'
|
||||||
else:
|
else:
|
||||||
|
|||||||
Reference in New Issue
Block a user