From d8e34229729a3e7fa564fb9427e1bf9f838bf883 Mon Sep 17 00:00:00 2001 From: Faik Uygur Date: Sat, 15 Apr 2006 11:53:45 +0000 Subject: [PATCH] =?UTF-8?q?Komutlar=20veritaban=C4=B1na=20yazma=20i=C5=9Fl?= =?UTF-8?q?emi=20yapmayaca=C4=9F=C4=B1m=20diyebilsin.=20Eskisi=20gibi=20ak?= =?UTF-8?q?si=20s=C3=B6ylenmedik=C3=A7e,=20hepsi=20yazacak=20=C5=9Fekilde?= =?UTF-8?q?=20a=C3=A7s=C4=B1n.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pisi/cli/commands.py | 4 ++-- pisi/lockeddbshelve.py | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/pisi/cli/commands.py b/pisi/cli/commands.py index 45e2cf10..1c69cc0d 100644 --- a/pisi/cli/commands.py +++ b/pisi/cli/commands.py @@ -137,12 +137,12 @@ class Command(object): else: self.authInfo = None - def init(self, database = True): + def init(self, database = True, write = True): """initialize PiSi components""" # NB: command imports here or in the command class run fxns import pisi.api - pisi.api.init(database = database, options = self.options, + pisi.api.init(database = database, write = write, options = self.options, comar = self.comar) def finalize(self): diff --git a/pisi/lockeddbshelve.py b/pisi/lockeddbshelve.py index 6025fc77..fe149568 100644 --- a/pisi/lockeddbshelve.py +++ b/pisi/lockeddbshelve.py @@ -76,7 +76,7 @@ def init_dbenv(write=False, writeversion=False): check_dbversion('filesdbversion', pisi.__filesdbversion__, write=write, update=writeversion) else: 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() flags = (db.DB_INIT_MPOOL | # cache 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.set_flags(db.DB_LOG_AUTOREMOVE, 1) # clear inactive logs automatically 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 #def open(filename, flags='r', mode = 0644, filetype = db.DB_BTREE): @@ -113,10 +115,8 @@ class LockedDBShelf(shelve.DBShelf): dbenv = ctx.dbenv shelve.DBShelf.__init__(self, dbenv) 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' - if not self.dbenv: - raise Error(_('Database writes not allowed without transactions')) elif os.access(filename, os.R_OK): flags = 'r' else: