Rahul,
some thoughts:

1) Your define_table() is executed at model time. When do you adjust
"now" contents?
2) I had this problem some time ago. The situation was I had created
my date field after some data was inserted in my table. So, this error
happened when I tried to retrieve some old data. I cleaned my table
and everything worked out.

--
Vinicius Assef.



On Tue, Nov 22, 2011 at 7:21 AM, Rahul <rahul.dhak...@gmail.com> wrote:
>
> What's inside "now"?
> Inside "now" contains this -
> import datetime; now = datetime.datetime.now() # For date time
>
> Vinicius, I am sorry about the messed up traceback - Never noticed
> that. simply copy-pasted the same. will take care in future (for now
> its pasted below again)
>
> But I don't understand why the code isnt working when I am serializing
> this in view? It seems to work on the db and even the below code works
> fine -
>
> def before_submit_of_update(form):
>        form.vars.updated_on= now
>        form.vars.posted_by = "Rahul"
>
> here "now" works fine. what is the problem when I am serializing it?
>
> Traceback (most recent call last):  [Reformatted ]
> File "D:\WEB2PY\web2py\gluon\restricted.py", line 194, in
> restricted    exec ccode in environment  File "D:/WEB2PY/web2py/
> applications/Link_IT/controllers/default.py", line 276, in <module>
> File "D:\WEB2PY\web2py\gluon\globals.py", line 149, in <lambda>
> self._caller = lambda f: f()  File "D:/WEB2PY/web2py/applications/
> Link_IT/controllers/default.py", line 58, in index    return
> dict(form=form, list_updates=db(db.updates).select())
> File "D:\WEB2PY\web2py\gluon\dal.py", line 5697, in select    return
> self.db._adapter.select(self.query,fields,attributes)
> File "D:\WEB2PY\web2py\gluon\dal.py", line 1233, in select    rows =
> response(sql)
> File "D:\WEB2PY\web2py\gluon\dal.py", line 1223, in response
> self.execute(sql)
> File "D:\WEB2PY\web2py\gluon\dal.py", line 1309, in execute    return
> self.log_execute(*a, **b)  File "D:\WEB2PY\web2py\gluon\dal.py", line
> 1304, in log_execute    ret = self.cursor.execute(*a,**b)
> File "C:\Python27\lib\sqlite3\dbapi2.py", line 66, in
> convert_timestamp    datepart, timepart = val.split(" ")ValueError:
> need more than 1 value to unpack
>
> I am working on other options for splitting etc.
>
> Thanks, Rahul D
> (www.flockbird.com) - web2py powered
>
>
>
> Regards, Rahul
> (www.flockbird.com - web2py powered)
>
>
> On Nov 21, 7:14 pm, Vinicius Assef <vinicius...@gmail.com> wrote:
>> Rahul, this is a str.split() error and it happens when there are less
>> pieces than str.split() expects.
>>
>> An example:
>>
>> >>> fullname = 'John Smith'
>> >>> (first_name, last_name) = fullname.split(" ")
>> >>> print 'first:', first_name, '- last:', last_name
>> John - Smith
>> >>> fullname = 'John'
>> >>> (first_name, last_name) = fullname.split(" ")
>>
>> Traceback (most recent call last):
>>   File "<pyshell#6>", line 1, in <module>
>>     (first_name, last_name) = fullname.split(" ")
>> ValueError: need more than 1 value to unpack
>>
>>
>>
>> There weren't 2 parts in fullname. That's why the error occured.
>>
>> Back to your problem, the same is happening with your updated_on
>> field. I'd make default=request.now on it.
>>
>> BTW, try organize the traceback. It helps people helping you.
>>
>> --
>> Vinicius Assef.
>>
>>
>>
>>
>>
>>
>>
>> On Mon, Nov 21, 2011 at 10:48 AM, Rahul <rahul.dhak...@gmail.com> wrote:
>> > Hi All,
>> >    Is there a solution for below traceback I posted (I am on 1.99.2,
>> > win7, firefox,ie9). Tried search for a solution in below thread .. no
>> > help ...
>>
>> >http://groups.google.com/group/web2py/browse_thread/thread/fc4a30879f...
>>
>> > Traceback
>> > 1.2.3.4.5.6.7.8.9.10.11.12.13.14.15.16.17.18.19.20.21.22.
>> > Traceback (most recent call last):  File "D:\WEB2PY\web2py\gluon
>> > \restricted.py", line 194, in restricted    exec ccode in environment
>> > File "D:/WEB2PY/web2py/applications/Link_IT/controllers/default.py",
>> > line 276, in <module>  File "D:\WEB2PY\web2py\gluon\globals.py", line
>> > 149, in <lambda>    self._caller = lambda f: f()  File "D:/WEB2PY/
>> > web2py/applications/Link_IT/controllers/default.py", line 58, in
>> > index    return dict(form=form, list_updates=db(db.updates).select())
>> > File "D:\WEB2PY\web2py\gluon\dal.py", line 5697, in select    return
>> > self.db._adapter.select(self.query,fields,attributes)  File "D:\WEB2PY
>> > \web2py\gluon\dal.py", line 1233, in select    rows = response(sql)
>> > File "D:\WEB2PY\web2py\gluon\dal.py", line 1223, in response
>> > self.execute(sql)  File "D:\WEB2PY\web2py\gluon\dal.py", line 1309, in
>> > execute    return self.log_execute(*a, **b)  File "D:\WEB2PY\web2py
>> > \gluon\dal.py", line 1304, in log_execute    ret =
>> > self.cursor.execute(*a,**b)  File "C:\Python27\lib\sqlite3\dbapi2.py",
>> > line 66, in convert_timestamp    datepart, timepart = val.split("
>> > ")ValueError: need more than 1 value to unpack
>>
>> > here is my controller (default.py) --------------
>>
>> > def index():
>> >  return dict( list_updates=db(db.updates).select())
>>
>> > here is the view (index.html) ---------
>>
>> > {{right_sidebar_enabled=False}}
>> > {{extend 'layout.html'}}
>> > {{=list_updates}}
>>
>> > my model (db.py)-------------
>>
>> > db.define_table('updates',
>> >                Field('description', 'text'),
>> >                Field('updated_on','date',  readable=False,
>> > writable=False, default=now),
>> >                Field('posted_by', readable=False, writable=False,
>> > length=512)
>> >                )
>>
>> > Please help .. what could be the issue.. I even cleared the db. the
>> > issue still persists.
>>
>> > Regards, Rahul
>

Reply via email to