Beispiel #1
0
 def logError(self, error_data):
     """Log the error in an XML file inside the user's AppData directory."""
     app_data_dir = getUserAppDataDirectory(self.getAppInfo("appShortName"))
     spec = self.PMError_LogSpec
     for k, v in error_data.items():
         error_data[k] = esc_xml(v)
     xml = spec % error_data
     filename = "error_%s.entry" % time.time()
     open(os.path.join(getUserAppDataDirectory(self.getAppInfo("appShortName")),
                       filename), "wb").write(xml)
Beispiel #2
0
	def __init__(self, key=None, crs=None, cxn=None, appName="Dabo", prefDb=None):
		if key is None:
			self._key = ""
		else:
			self._key = key
		self._cache = {}
		self._deletionCache = {}
		self._autoPersist = True
		# Do we save even without a base key? This should only
		# be changed by framework tools designed to access the
		# the preference database.
		self._persistAll = False
		super(dPref, self).__init__()
		self._parent = None
		self._noneType = type(None)
		self._typeDict = {int: "int", float: "float", long: "long", str: "str", unicode: "unicode",
				bool: "bool", list: "list", tuple: "tuple", datetime.date: "date", dict: "dict",
				datetime.datetime: "datetime", Decimal: "decimal", self._noneType: "none",
				dabo.db.dDataSet: "tuple"}
		if crs is None:
			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")
			if cxn:
				self._cxn = cxn
			else:
				self._cxn = dabo.db.dConnection(connectInfo={"DbType": "SQLite", "Database": db},
						forceCreate=True)
			self._cursor = self._cxn.getDaboCursor()
			self._cursor.IsPrefCursor = True
			# Make sure that the table exists
			if not  "daboprefs" in self._cursor.getTables():
				self._cursor.execute("create table daboprefs (ckey text not null, ctype text not null, cvalue text not null)")
				self._cursor.commitTransaction()
		else:
			self._cursor = crs
			self._cxn = cxn
Beispiel #3
0
 def __init__(self,
              key=None,
              crs=None,
              cxn=None,
              appName="Dabo",
              prefDb=None):
     if key is None:
         self._key = ""
     else:
         self._key = key
     self._cache = {}
     self._deletionCache = {}
     self._autoPersist = True
     # Do we save even without a base key? This should only
     # be changed by framework tools designed to access the
     # the preference database.
     self._persistAll = False
     super(dPref, self).__init__()
     self._parent = None
     self._noneType = type(None)
     self._typeDict = {
         int: "int",
         float: "float",
         long: "long",
         str: "str",
         unicode: "unicode",
         bool: "bool",
         list: "list",
         tuple: "tuple",
         datetime.date: "date",
         dict: "dict",
         datetime.datetime: "datetime",
         Decimal: "decimal",
         self._noneType: "none",
         dabo.db.dDataSet: "tuple"
     }
     if crs is None:
         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")
         if cxn:
             self._cxn = cxn
         else:
             self._cxn = dabo.db.dConnection(connectInfo={
                 "DbType": "SQLite",
                 "Database": db
             },
                                             forceCreate=True)
         self._cursor = self._cxn.getDaboCursor()
         self._cursor.IsPrefCursor = True
         # Make sure that the table exists
         if not "daboprefs" in self._cursor.getTables():
             self._cursor.execute(
                 "create table daboprefs (ckey text not null, ctype text not null, cvalue text not null)"
             )
             self._cursor.commitTransaction()
     else:
         self._cursor = crs
         self._cxn = cxn