On 7 Nov 2013, at 6:00 AM, Anthony <abasta...@gmail.com> wrote:

> Actually, my original explanation wasn't quite correct -- I made the 
> corrections in the original post (same conclusion though -- #2 should be 
> preferred, but they should both result in nearly the same value). I don't see 
> how using datetime.now would lead to the error you are getting, but go ahead 
> and make the change and see if it helps.

What was the correction? Seems to me if #1 works at all it's because it's 
getting recognized as a function and called; str() doesn't call it, at least in 
my testing.

The insufficient-data message seems to be triggered by some kind of type 
mismatch. Date vs str? Hard to see how that would be intermittent, though.

> 
> You also might consider logged the SQL statements that get executed so you 
> can examine the raw SQL that is producing the errors. That should tell you 
> what is going wrong.
> 
> Anthony
> 
> On Thursday, November 7, 2013 8:48:40 AM UTC-5, at wrote:
> Thanks Anthony for the explanation.
> 
> We are using #1 and occasionally get 'insufficient data left in message', 
> could it be because of datetime.now?
> 
> On Thursday, 7 November 2013 17:56:47 UTC+5, Anthony wrote:
> Is there any difference between following two statements:
> #1
> from datetime import datetime
> db.my_table.insert(updated=datetime.now)
> 
> and 
> #2
> from datetime import datetime
> db.my_table.insert(updated=datetime.now())
> 
> I believe they should result in (almost) the same entry into the database. In 
> #1, you are technically inserting the function datetime.now. However, 
> ultimately, the value inserted will be str(datetime.now), which turns out to 
> be the string representation of datetime.now(). So, the only difference is 
> that in the second case, the value of datetime.now() is determined before the 
> .insert() method is called, and in the first case, the value is determined 
> within the call to .insert() (the difference in time would probably only be 
> microseconds).
> 
> Note, you should use #2, as the fact that #1 works is due to an 
> implementation detail (i.e., the fact that str() is applied to the value 
> provided) -- you should not rely on that behavior, as it could change in the 
> future, which would break your code.
> 
> Anthony
> 

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to