They should both operate the same in any case. -Thadeus
On Mon, Mar 29, 2010 at 12:00 PM, Thadeus Burgess <thade...@thadeusb.com> wrote: > I almost want to say that as long as it is still a python object it > should stay python objects. > > That being said, we already have the datetime_to_str flag, leave the > defaults as they were if someone wants it differently they can alter > the flag. > > -Thadeus > > > > > > On Sun, Mar 28, 2010 at 10:09 AM, Iceberg <iceb...@21cn.com> wrote: >> Did not really try it yet, just look into the source code here [1]. So >> there are actually three relevant places: >> Row.as_dict(...,datetime_to_str=False) # was datetime_to_str=True >> Rows.as_dict(...,datetime_to_str=True) # did not change this time >> Rows.as_list(...,datetime_to_str=True) # did not change this time >> >> IMO, as long as: >> a. row.as_dict() is instead used internally (Well, Tito uses it >> anyway, but he is happy with the change.) >> b. Most people use Rows.as_dict() and Rows.as_list(), and their >> default datetime_to_str=True are not changed. >> >> then this modification is fine ... for me. I don't know what others >> think. Generally speaking, it is not a necessary change since users >> already has a datetime_to_str flag to toggle. So, count me neutral. >> >> Regards, >> Iceberg >> >> [1]: >> http://code.google.com/p/web2py/source/diff?spec=svn5beee338c7dfa1fdbf259f987f5a32460c02a553&r=5beee338c7dfa1fdbf259f987f5a32460c02a553&format=side&path=/gluon/sql.py >> >> On Mar26, 7:21am, mdipierro <mdipie...@cs.depaul.edu> wrote: >>> I just made some changes to sql.py in trunk that does what you say. >>> The main purpose it for testing it and see what other people have to >>> say. >>> >>> I have to changes: >>> 1) as_dict now behaves by default as as_list (i.e datetime is >>> converted to string by default) >>> 2) when rows and records are stored in a session, datetime is NOT >>> serialized into a string >>> >>> This may be seen by some as not backward compatible and this behavior >>> was not documented anyway. Yet, I want to hear other people opinions >>> and want if this breaks people applications. >>> >>> Massimo >>> >>> On Mar 25, 5:59 pm, Tito Garrido <titogarr...@gmail.com> wrote: >>> >>> >>> >>> > What about as_dict(datetime_to_str=True)? >>> >>> > On Thu, Mar 25, 2010 at 7:33 PM, mdipierro <mdipie...@cs.depaul.edu> >>> > wrote: >>> > > On a second though, this cannot be changed, because it will break web >>> > > services example and therefore backward compatibility. @service.xmlrpc >>> > > for example cannot serialize datetime. >>> >>> > > Anyway you can do >>> >>> > > ...select().as_list(datetime_to_str=False) >>> >>> > > On Mar 25, 4:58 pm, Tito Garrido <titogarr...@gmail.com> wrote: >>> > > > I prefer the serialized data on as_dict result :) >>> >>> > > > On Thu, Mar 25, 2010 at 6:36 PM, mdipierro <mdipie...@cs.depaul.edu> >>> > > wrote: >>> > > > > That's how it is. There are historical reasons for it. >>> >>> > > > > select().as_dict(...) was designed to return a representation that >>> > > > > could be serialized by simplejson and other serializers. simplejson >>> > > > > cannot serialize date/datetime/time objects. This is no longer the >>> > > > > case since I patched simplejson. >>> >>> > > > > row.as_dict() is instead used internally to compare two records. >>> >>> > > > > I think we can change one or the other and make them consistent. >>> > > > > What >>> > > > > do people think? >>> >>> > > > > Massimo >>> >>> > > > > On Mar 25, 4:29 pm, Tito Garrido <titogarr...@gmail.com> wrote: >>> > > > > > as_list on a select returns something like: >>> >>> > > > > > [{'id': 11, 'time': '08:00:00'}] >>> >>> > > > > > using as_dict on a record returns: >>> >>> > > > > > [{'id': 11, 'horario': datetime.time(8, 0)}] >>> >>> > > > > > Is that expected? >>> >>> > > > > > Regards, >>> >>> > > > > > Tito >> >> -- >> You received this message because you are subscribed to the Google Groups >> "web2py-users" group. >> To post to this group, send email to web...@googlegroups.com. >> To unsubscribe from this group, send email to >> web2py+unsubscr...@googlegroups.com. >> For more options, visit this group at >> http://groups.google.com/group/web2py?hl=en. >> >> > -- You received this message because you are subscribed to the Google Groups "web2py-users" group. To post to this group, send email to web...@googlegroups.com. To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/web2py?hl=en.