dabo Commit
Revision 6316
Date: 2011-01-14 13:40:23 -0800 (Fri, 14 Jan 2011)
Author: Jacekk
Trac: http://trac.dabodev.com/changeset/6316
Changed:
U trunk/dabo/dPref.py
Log:
Added 'prefDb' parameter that allows to point preferences database directly.
Now it's possible to put preferences data, e.g. in application
home subdirectory and makes it roaming when application resides on removable
storage like flash drive.
Diff:
Modified: trunk/dabo/dPref.py
===================================================================
--- trunk/dabo/dPref.py 2011-01-14 18:56:01 UTC (rev 6315)
+++ trunk/dabo/dPref.py 2011-01-14 21:40:23 UTC (rev 6316)
@@ -45,7 +45,7 @@
will not be saved. Calling 'persist()' will write any values of that
object and all of its
child objects to the database.
"""
- def __init__(self, key=None, crs=None, cxn=None, appName="Dabo"):
+ def __init__(self, key=None, crs=None, cxn=None, appName="Dabo",
prefDb=None):
if key is None:
self._key = ""
else:
@@ -64,15 +64,18 @@
bool: "bool", list: "list", tuple: "tuple",
datetime.date: "date", dict: "dict",
datetime.datetime: "datetime", Decimal:
"decimal", self._noneType: "none"}
if crs is None:
- prefdir = utils.getUserAppDataDirectory(appName)
- if prefdir is None:
- # pkm: This happened to me on a webserver where
the user is www-data who doesn't have
- # a home directory. I actually don't care
about preferences in this case but I
- # wasn't able to set
dApp.PreferenceManager to None unfortunately, so we'll just
- # punt and put the preference db in the
working directory (up to your webapp to
- # chdir() accordingly)..
- prefdir = os.getcwd()
- db = os.path.join(prefdir, "DaboPreferences.db")
+ if prefDb:
+ db = prefDb
+ else:
+ prefdir = utils.getUserAppDataDirectory(appName)
+ if prefdir is None:
+ # pkm: This happened to me on a
webserver where the user is www-data who doesn't have
+ # a home directory. I actually
don't care about preferences in this case but I
+ # wasn't able to set
dApp.PreferenceManager to None unfortunately, so we'll just
+ # punt and put the preference db
in the working directory (up to your webapp to
+ # chdir() accordingly)..
+ prefdir = os.getcwd()
+ db = os.path.join(prefdir, "DaboPreferences.db")
self._cxn = dabo.db.dConnection(connectInfo={"DbType":
"SQLite", "Database": db},
forceCreate=True)
self._cursor = self._cxn.getDaboCursor()
_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-dev
Searchable Archives: http://leafe.com/archives/search/dabo-dev
This message:
http://leafe.com/archives/byMID/[email protected]