dabo Commit
Revision 6601
Date: 2011-05-25 15:30:47 -0700 (Wed, 25 May 2011)
Author: Paul
Trac: http://trac.dabodev.com/changeset/6601
Changed:
U trunk/dabo/db/dDataSet.py
Log:
Committed patch from Adrian Klaver that adds optional TypeStructure property
to dDataSet for the developer to provide hints to dDataSet so table structure
gets created with the expected data types.
Diff:
Modified: trunk/dabo/db/dDataSet.py
===================================================================
--- trunk/dabo/db/dDataSet.py 2011-05-25 19:23:01 UTC (rev 6600)
+++ trunk/dabo/db/dDataSet.py 2011-05-25 22:30:47 UTC (rev 6601)
@@ -48,6 +48,7 @@
self._cursor = None
self._bizobj = None
self._populated = False
+ self._typeStructure = {}
# We may need to encode fields that are not legal names.
self.fieldAliases = {}
# Keep a hash value to tell if we need to re-populate
@@ -66,6 +67,7 @@
datetime.datetime: "timestamp", Decimal:
"decimal"}
+
def __del__(self):
if self._cursor is not None:
self._cursor.close()
@@ -276,8 +278,11 @@
self.fieldAliases[safekey] = key
else:
safekey = key
- typ = type(rec[key])
try:
+ typ =
dabo.db.getPythonType(self._typeStructure[key][0])
+ except KeyError:
+ typ = type(rec[key])
+ try:
retList.append("%s %s" % (safekey,
ds._typeDict[typ]))
except KeyError:
retList.append(safekey)
@@ -444,7 +449,13 @@
ret = ret._sourceDataSet
return ret
+ def _getTypeStructure(self):
+ return self._typeStructure
+ def _setTypeStructure(self, val):
+ self._typeStructure = val
+
+
Bizobj = property(_getBizobj, _setBizobj, None,
_("Reference to the bizobj that 'owns' this data set.
Default=None (bizobj)"))
@@ -452,11 +463,13 @@
_("Reference to the bizobj that 'owns' this data set.
Default=None (dCursorMixin)"))
Encoding = property(_getEncoding, _setEncoding, None,
- _(" The encoding used for data in the dataset. (str)"))
+ _("The encoding used for data in the dataset. (str)"))
UnfilteredDataSet = property(_getUnfilteredDataSet, None, None,
_("""If filters have been applied, returns the
unfiltered dataset that would be returned if removeFilters() had been called.
If no filters have been applied, returns self (dDataSet)"""))
+ TypeStructure = property(_getTypeStructure, _setTypeStructure, None,
+ _("""An optional helper dictionary matching field names
to dabo data types."""))
_______________________________________________
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]