[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
r5139 - trunk/gnue-appserver/src
From: |
reinhard |
Subject: |
r5139 - trunk/gnue-appserver/src |
Date: |
Thu, 19 Feb 2004 07:21:02 -0600 (CST) |
Author: reinhard
Date: 2004-02-19 07:21:01 -0600 (Thu, 19 Feb 2004)
New Revision: 5139
Modified:
trunk/gnue-appserver/src/data.py
Log:
Document string vs. unicode issues.
Modified: trunk/gnue-appserver/src/data.py
===================================================================
--- trunk/gnue-appserver/src/data.py 2004-02-19 11:29:27 UTC (rev 5138)
+++ trunk/gnue-appserver/src/data.py 2004-02-19 13:21:01 UTC (rev 5139)
@@ -317,6 +317,11 @@
Returns a recordset object. All fields given in 'fields' are fetched from
the database and cached, so that subsequential access to those fields won't
trigger another access to the db backend.
+
+ Table and field names must be strings.
+
+ Field values in conditions must be in native Python type; in case of
+ strings they must be Unicode.
"""
return recordset (self.__cache, self.__connections, self.__database, table,
@@ -332,7 +337,7 @@
result = ''
for i in range (0, 32):
result = result + str (int (whrandom.random () * 10))
- return result
+ return unicode (result)
# ---------------------------------------------------------------------------
# Create a new record
@@ -341,6 +346,8 @@
def insertRecord (self, table):
"""
Inserts a new record. A 'gnue_id' is assigned automatically.
+
+ Table must be a string.
"""
id = self.__generateId ()
@@ -358,6 +365,8 @@
Deletes the given record (acutally marks it for deletion on commit). All
data of the record will stay available until commit, but the field
'gnue_id' will seem to have a value of None.
+
+ Table must be a string, row must be Unicode.
"""
if not self.__cache.has (table, row, 'gnue_id'): # not yet in cache
@@ -375,6 +384,8 @@
won't trigger another access to the db backend.
This method won't query the db backend for data which is already cached.
+
+ Table and fields must be a string, row must be Unicode.
"""
uncachedFields = []
@@ -582,6 +593,9 @@
"""
Get the value for a field. If the value isn't cached, a new query to the
database is issued to get the value.
+
+ The field name must be given as a string. The result will be returned as
+ the native Python datatype, in case of a string field it will be Unicode.
"""
if self.__cache.has (self.__table, self.__row, field):
@@ -605,6 +619,9 @@
def putField (self, field, value):
"""
Put the value for a field.
+
+ The field name must be given as a string, value must be the native Python
+ datatype of the field, in case of a string field it must be Unicode.
"""
self.__cache.write (self.__table, self.__row, field, value, 1)
@@ -632,17 +649,17 @@
print 'Ok'
print 'record.getField with prefetched data ...',
- print r.getField ('address_name')
+ print repr (r.getField ('address_name'))
print 'record.getField with non-prefetched data ...',
- print r.getField ('address_city')
+ print repr (r.getField ('address_city'))
print 'recordset.nextRecord ...',
r = rs.nextRecord ()
print 'Ok'
print 'record.getField with prefetched data ...',
- print r.getField ('address_name')
+ print repr (r.getField ('address_name'))
print 'connection.insertRecord ...',
r = c.insertRecord ('address_person')
@@ -650,14 +667,14 @@
print 'record.getField ...',
id = r.getField ('gnue_id')
- print id
+ print repr (id)
print 'record.putField ...',
- r.putField ('address_name', 'New Person')
+ r.putField ('address_name', u'New Person')
print 'Ok'
print 'record.getField of inserted data ...',
- print r.getField ('address_name')
+ print repr (r.getField ('address_name'))
print 'connection.commit with an inserted record ...',
c.commit ()
@@ -666,7 +683,7 @@
print 'connection.query for previously inserted record ...',
rs = c.query ('address_person', ['address_name'],
[['eq', ''], ['field', 'address_name'],
- ['const', 'New Person']], None)
+ ['const', u'New Person']], None)
print 'Ok'
print 'recordset.firstRecord ...',
@@ -674,42 +691,42 @@
print 'Ok'
print 'record.getField with prefetched data ...',
- print r.getField ('address_name')
+ print repr (r.getField ('address_name'))
print 'record.putField of prefetched data ...',
- r.putField ('address_name', 'New Name')
+ r.putField ('address_name', u'New Name')
print 'Ok'
print 'record.putField of non-prefetched data ...',
- r.putField ('address_city', 'New City')
+ r.putField ('address_city', u'New City')
print 'Ok'
print 'record.getField of changed data ...',
- print r.getField ('address_name')
+ print repr (r.getField ('address_name'))
print 'connection.findRecord for previously changed record ...',
r = c.findRecord ('address_person', id, ['address_name'])
print 'Ok'
print 'record.getField of changed data, independent query ...',
- print r.getField ('address_city')
+ print repr (r.getField ('address_city'))
print 'connection.commit with a changed record ...',
c.commit ()
print 'Ok'
print 'record.getField of prefetched data ...',
- print r.getField ('address_name')
+ print repr (r.getField ('address_name'))
print 'connection.deleteRecord ...',
c.deleteRecord ('address_person', id)
print 'Ok'
print 'record.getField of deleted uncommitted record, prefetched ...',
- print r.getField ('address_name')
+ print repr (r.getField ('address_name'))
print 'record.getField of deleted uncommitted record, non-prefetched ...',
- print r.getField ('address_city')
+ print repr (r.getField ('address_city'))
print 'connection.commit with a deleted record ...',
c.commit ()
@@ -717,7 +734,7 @@
print 'check if the record is really gone now ...',
rs = c.query ('address_person', ['address_name'],
- [['eq', ''], ['field', 'address_city'], ['const', 'New City']],
+ [['eq', ''], ['field', 'address_city'], ['const', u'New
City']],
None)
if rs.firstRecord () != None:
raise Exception
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- r5139 - trunk/gnue-appserver/src,
reinhard <=