On Tuesday, July 21, 2020 at 3:16:29 AM UTC-7, villas wrote:
>
> Your my_validator function iterates through the whole table. This is OK
> when you have a few records, but very inefficient if you have
> thousands/millions. Why not simply query the table? Something like this...
>
> def my_validator(form):
> if db((db.lecture.id == form.vars.id) & (db.lecture.lecture_time ==
> form.vars.lecture_time)
> ).count() >0:
> form.errors.lecturer=SPAN("Record already exists",
> _style="font-weight:
> bold;")
>
>
Ah, thank you. I thought I was overlooking something, but late-night code
reviews can be a challenge.
/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].
To view this discussion on the web visit
https://groups.google.com/d/msgid/web2py/d9b4e112-1606-423d-8bed-e5ff99d39dd1o%40googlegroups.com.