Hello guys,
I'm struggling with a problem that's driving me crazy. The validator
IS_NOT_IN_DB which I use for my object "tag" does not work for me.
# TAG
db.define_table('tag',
Field('name', requires=(IS_SLUG(), IS_LOWER(), IS_NOT_IN_DB(
db, 'tag.name'))),
Field('is_public', 'boolean', default=False, readable=False,
writable=False),
auth.signature,
common_filter = lambda query: db.tag.is_public == True)
db.tag.name.requires = IS_NOT_IN_DB(db, 'tag.name')
As you can see, there are two ways I made sure that no duplicates can be
created, in the name field itself and outside of the table definition.
Registered user can suggest tags:
Although the tag "test" has already been submitted twice I could submit it
a third time.
The function looks as follows:
What I already tried (without improvement):
- adding "unique=True" to the name field
- just using .process() without "onvalidation"
- "ignore_common_filters" on and off
- inside the "my_form_processing"-method I checked if the amount of db
objects with the given name is > 0 , but i could not figure out how to stop
the form from processing
Please let me know how I can fix that problem.
Thanks!
Jay
--
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/d05b3734-a26a-4005-8ae2-d32b0bea7487%40googlegroups.com.