by belford » Wed Aug 28, 2013 10:05 pm
Yes, str.split() works. Most of the methods on str objects are now available. (str.format is the major exception, because I'm not sure about new-style formatting yet. str % (arg, arg, arg) works.)
datetime.timedelta is *not* one of the DB-storable types (although datetime.datetime is). If you try to assign "timeelapsed = datetime.timedelta(1,2,3)" you'll get an "Cannot encode object" exception.
So you must be doing something else. Your exception is reporting "dict.total_seconds" as the problem, so timeelapsed must be a dict object of some sort. Typing "/getprop timeelapsed" should display it.
If you need to store a duration in the database, you should store the total_seconds() value. For example, if t1 and t2 are datetimes, then (t1-t2) is a timedelta. You can't assign "timeelapsed = (t1-t2)" but you could do "timeelapsed = (t1-t2).total_seconds()".