[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnue] r7364 - in trunk/gnue-common/src/datasources/drivers: Base file
From: |
reinhard |
Subject: |
[gnue] r7364 - in trunk/gnue-common/src/datasources/drivers: Base file |
Date: |
Thu, 14 Apr 2005 11:03:59 -0500 (CDT) |
Author: reinhard
Date: 2005-04-14 11:03:58 -0500 (Thu, 14 Apr 2005)
New Revision: 7364
Modified:
trunk/gnue-common/src/datasources/drivers/Base/RecordSet.py
trunk/gnue-common/src/datasources/drivers/file/Base.py
trunk/gnue-common/src/datasources/drivers/file/csvfile.py
trunk/gnue-common/src/datasources/drivers/file/dbffile.py
Log:
Try to finally put an end to the uppercase vs. lowercase fieldname mess.
Modified: trunk/gnue-common/src/datasources/drivers/Base/RecordSet.py
===================================================================
--- trunk/gnue-common/src/datasources/drivers/Base/RecordSet.py 2005-04-14
16:00:02 UTC (rev 7363)
+++ trunk/gnue-common/src/datasources/drivers/Base/RecordSet.py 2005-04-14
16:03:58 UTC (rev 7364)
@@ -41,10 +41,37 @@
tablename = '', boundFields = [], readonly = False, masterRecord = None,
masterKeyFields = [], masterLinkFields = [], defaultValues = {},
rowidField = None, primarykeyFields = []):
+ """
+ Create a new RecordSet instance.
+ @param parent: ResultSet this RecordSet is a part of.
+ @param initialData: Dictionary with the record's data if it's an existing
+ record. Keys of the dictionary are field names.
+ @param connection: GConnection object the RecordSet object can use to post
+ changes.
+ @param tablename: Table name.
+ @param boundFields: List of fields to be included when posting changes to
+ the backend. All fields not in this list are considered unbound fields
+ and are not persistent.
+ @param readonly: True if the RecordSet is read only. If set, an attempt to
+ modify or delete this record raises an exception.
+ @param masterRecord: RecordSet instance of the master of this record, or
+ None if this record has no master.
+ @param masterKeyFields: Fields in the master record matching the
+ masterLinkFields in this record.
+ @param masterLinkFields: Fields in this record matching the masterKeyFields
+ of the master record.
+ @param defaultValues: Dictionary with default data to be used if it is a
+ new record (i.e. initialData is an empty dictionary).
+ @param rowidField: Field name of the field containing a unique row id
+ generated by the backend, if available.
+ @param primaryKeyFields: List of field names that make up a unique key, if
+ available.
+ """
+
self.__connection = connection
self.__tablename = tablename
- self.__boundFields = [f.lower () for f in boundFields]
+ self.__boundFields = boundFields
self.__readonly = readonly
self.__masterRecord = masterRecord
self.__masterKeyFields = masterKeyFields
@@ -60,11 +87,10 @@
# The ResultSet this RecordSet is a part of - FIXME: should be private
self._parent = parent
- # The field values, keys are lowercase
+ # The field values
self.__fields = {}
- # If field name is present as a key, then field has been modified; keys are
- # lowercase
+ # If field name is present as a key, then field has been modified
self.__modifiedFlags = {}
# The detail ResultSets where this record is the master
@@ -82,7 +108,7 @@
# Existing record:
# Set the current state of all fields as given in the parameter
for (field, value) in initialData.items ():
- self.__fields [field.lower ()] = value
+ self.__fields [field] = value
else:
@@ -107,7 +133,7 @@
if self.__primarykeyFields:
primarykeyIsComplete = True
for fieldname in self.__primarykeyFields:
- if self.__fields [fieldname.lower ()] is None:
+ if self.__fields [fieldname] is None:
primarykeyIsComplete = False
break
if primarykeyIsComplete:
@@ -127,16 +153,15 @@
# Field access
# ---------------------------------------------------------------------------
- def getField (self, field):
+ def getField (self, fieldname):
"""
Return the current value of a field.
- @param field: Field name, case insensitive.
+ @param fieldname: Field name.
@return: Field value.
"""
- fn = field.lower ()
- if self.__fields.has_key (fn):
- return self.__fields [fn]
+ if self.__fields.has_key (fieldname):
+ return self.__fields [fieldname]
else:
# FIXME: If a field value has yet to be set (either from a query or via a
# setField), then __fields will not contain a key for the requested field
@@ -161,8 +186,8 @@
"""
Set a new value for a field.
- @param fieldname: Field name, case insensitive
- @param value: Value to set
+ @param fieldname: Field name.
+ @param value: Value to set.
"""
if fieldname in self.__boundFields and self.__readonly:
@@ -193,14 +218,14 @@
# ---------------------------------------------------------------------------
- def isFieldModified (self, field):
+ def isFieldModified (self, fieldname):
"""
Determine whether a field of this record has local modifications.
- @param field: Field name, case insensitive
- @return: True if the field has local modifications, False otherwise
+ @param fieldname: Field name.
+ @return: True if the field has local modifications, False otherwise.
"""
- return self.__modifiedFlags.has_key (field.lower ())
+ return self.__modifiedFlags.has_key (fieldname)
# ---------------------------------------------------------------------------
@@ -522,7 +547,7 @@
"""
self._cachedDetailResultSets [resultSet._dataObject] = resultSet
for field in resultSet._dataObject._masterfields:
- self.__detailLinkFlags [field.lower ()] = True
+ self.__detailLinkFlags [field] = True
# ---------------------------------------------------------------------------
@@ -564,7 +589,6 @@
# useful to initialize a new record: the record will still be regarded as
# "empty", but the field will be included in any following insert
# statement.
- fieldname = fieldname.lower ()
self.__fields [fieldname] = value
self.__modifiedFlags [fieldname] = True
Modified: trunk/gnue-common/src/datasources/drivers/file/Base.py
===================================================================
--- trunk/gnue-common/src/datasources/drivers/file/Base.py 2005-04-14
16:00:02 UTC (rev 7363)
+++ trunk/gnue-common/src/datasources/drivers/file/Base.py 2005-04-14
16:03:58 UTC (rev 7364)
@@ -257,6 +257,6 @@
@param table: Table name (only useful if a file can contain more than one
table)
@return: List of fieldname/value dictionaries containing all data of the
- complete file, where the keys in the dictionary must be lower case.
+ complete file.
"""
return []
Modified: trunk/gnue-common/src/datasources/drivers/file/csvfile.py
===================================================================
--- trunk/gnue-common/src/datasources/drivers/file/csvfile.py 2005-04-14
16:00:02 UTC (rev 7363)
+++ trunk/gnue-common/src/datasources/drivers/file/csvfile.py 2005-04-14
16:03:58 UTC (rev 7364)
@@ -51,9 +51,9 @@
f.seek (0)
# Read the first row to get the field names
- headers = (csv.reader (f, dialect = dialect)).next ()
+ fieldnames = (csv.reader (f, dialect = dialect)).next ()
- return (f, dialect, headers)
+ return (f, dialect, fieldnames)
# ---------------------------------------------------------------------------
@@ -62,11 +62,11 @@
def _listFields (self, filename, table):
- (f, dialect, headers) = self.__prepareFile (filename)
+ (f, dialect, fieldnames) = self.__prepareFile (filename)
- for field in headers:
- yield {'id': field,
- 'name': field,
+ for fieldname in fieldnames:
+ yield {'id': fieldname,
+ 'name': fieldname,
'type': 'field',
'nativetype': 'text',
'datatype': 'text',
@@ -79,9 +79,8 @@
def _loadFile (self, filename, table):
- (f, dialect, headers) = self.__prepareFile (filename)
+ (f, dialect, fieldnames) = self.__prepareFile (filename)
- fieldnames = [field.lower () for field in headers]
reader = csv.DictReader (f, fieldnames, dialect = dialect)
# Make a real list of dictionaries
Modified: trunk/gnue-common/src/datasources/drivers/file/dbffile.py
===================================================================
--- trunk/gnue-common/src/datasources/drivers/file/dbffile.py 2005-04-14
16:00:02 UTC (rev 7363)
+++ trunk/gnue-common/src/datasources/drivers/file/dbffile.py 2005-04-14
16:03:58 UTC (rev 7364)
@@ -68,7 +68,7 @@
f = dbf.dbf (filename)
- fieldnames = [(field [0]).lower () for field in f.fields]
+ fieldnames = [field [0] for field in f.fields]
# Make a real list of dictionaries
return [dict (zip (fieldnames, record)) for record in f]
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [gnue] r7364 - in trunk/gnue-common/src/datasources/drivers: Base file,
reinhard <=