I share with you a solution that gives leonel camara to a problem that I encounter
my question : users must score the hours or minutes of work performed on the project. it's for Timesheet software. obligation: the data must be store in database , so virtual field impossible. the solution was give by leonel camara (thanks lot!!) one thing you can do is store the time in the database as an integer representing minutes or seconds if you need that much resolution the user can input hours minutes etc and you convert it to a single number in minutes. from gluon.validators import Validator, translate, regex_time class IS_SECONDS(Validator): def __init__(self, error_message='Enter time as hh:mm:ss'): self.error_message = error_message def __call__(self, value): try: ivalue = value value = regex_time.match(value.lower()) (h, m, s) = (int(value.group('h')), 0, 0) if not value.group('m') is None: m = int(value.group('m')) if not value.group('s') is None: s = int(value.group('s')) return (h*3600 + m*60 + s, None) except AttributeError: pass except ValueError: pass return (ivalue, translate(self.error_message)) db.define_table('planing', Field('seconds_worked', 'integer', widget=SQLFORM.widgets.time.widget, requires=IS_SECONDS(), label=T('Time Worked')), Field('seconds_holidays', 'integer', widget=SQLFORM.widgets.time.widget, requires=IS_SECONDS(), label=T('Time Holidays')), Field('seconds_total', 'integer', writable=False, compute=lambda row: row.seconds_worked + row.seconds_holidays) ) -- 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/d/optout.