summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: eb25ddf)
raw | patch | inline | side by side (parent: eb25ddf)
author | schlatterbeck <schlatterbeck@57a73879-2fb5-44c3-a270-3262357dd7e2> | |
Mon, 21 Mar 2011 20:49:56 +0000 (20:49 +0000) | ||
committer | schlatterbeck <schlatterbeck@57a73879-2fb5-44c3-a270-3262357dd7e2> | |
Mon, 21 Mar 2011 20:49:56 +0000 (20:49 +0000) |
object, use that for creation of the roundup Date object -- don't
convert to string first
git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/roundup/trunk@4582 57a73879-2fb5-44c3-a270-3262357dd7e2
convert to string first
git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/roundup/trunk@4582 57a73879-2fb5-44c3-a270-3262357dd7e2
roundup/backends/rdbms_common.py | patch | blob | history |
index 9c7d7219f26cddd5fae6e8e39831ac0e8bbdcdf7..eb1b7c9a33e777053775b656a1c759a54ba25be2 100644 (file)
__docformat__ = 'restructuredtext'
# standard python modules
-import sys, os, time, re, errno, weakref, copy, logging
+import sys, os, time, re, errno, weakref, copy, logging, datetime
# roundup modules
from roundup import hyperdb, date, password, roundupdb, security, support
from roundup.support import reversed
from roundup.i18n import _
+
# support
from roundup.backends.blobfiles import FileStorage
try:
# assume it's a number returned from the db API
return int(value)
+def date_to_hyperdb_value(d):
+ """ convert date d to a roundup date """
+ if isinstance (d, datetime.datetime):
+ return date.Date(d)
+ return date.Date (str(d).replace(' ', '.'))
+
+
def connection_dict(config, dbnamestr=None):
""" Used by Postgresql and MySQL to detemine the keyword args for
opening the database connection."""
sql_to_hyperdb_value = {
hyperdb.String : str,
- hyperdb.Date : lambda x:date.Date(str(x).replace(' ', '.')),
+ hyperdb.Date : date_to_hyperdb_value,
# hyperdb.Link : int, # XXX numeric ids
hyperdb.Link : str,
hyperdb.Interval : date.Interval,
name = p.name
assert (name)
classes[key][name] = p
+ p.to_hyperdb = self.db.to_hyperdb_value(p.propclass.__class__)
while True:
row = cursor.fetchone()
if not row: break
for propname, p in pt.iteritems():
value = row[p.sql_idx]
if value is not None:
- cls = p.propclass.__class__
- value = self.db.to_hyperdb_value(cls)(value)
+ value = p.to_hyperdb(value)
node[propname] = value
self.db._cache_save(key, node)
yield str(row[0])