On Tuesday, February 9, 2016 at 12:14:08 PM UTC-8, 黄祥 wrote: > > is it possible to have default value condition base on time? i tried > before but return an error > e.g. 1 > > table.shift.default = 1 if request.now.hour() >= 0 & request.now.hour() <= 8 > else 2 if request.now.hour() >= 8 & request.now.hour() <= 16 else 3 > TypeError: 'int' object is not callable > > request.now.hour isn't a function, it looks like, which fits with request.now being a datetime.datetime object ... hour is an attribute. Take out the parens.
> e.g. 2 > table.shift.default = 1 if int(request.now.hour() ) >= 0 & int(request.now.hour() ) <= 8 else 2 if int(request.now.hour() ) >= 8 & int(request.now.hour() ) <= 16 else 3 > TypeError: 'int' object is not callable > > any idea how to achive it in web2py way? > > /dps -- 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 [email protected]. For more options, visit https://groups.google.com/d/optout.

