something like this?

class is_less_than:
   def __init__(self,value,error_message='oops'):
       self.value, self.error_messages=value, error_message
   def __call__(self,value):
       try:
           other=datetime.datetime.strptime(self.value,'%Y-%m-%d %H:%M:
%S')
           if value<other: return (value,None)
           raise ValueError
       except ValueError:
           return (value,self.error_massage)

db.openinghours.from_time.requires=is_less_than(request.vars.to_time)

On Dec 8, 5:04 am, annet <annet.verm...@gmail.com> wrote:
> I have a table that contains opening hours. I would like to validate
> that the from_time is less than the to_time.
>
> I tried:
>
> db.openinghours.from_time.requires=db.openinghours.from_time<db.openinghours.to_time
>
> ... but that doesn't work. What is the correct syntax to implement
> this?
>
> Kind regards,
>
> Annet.

--

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.


Reply via email to