I want to prevent users from choosing a db.auth_group.role name that is an 
integer because integer names for roles are reserved fro admin purposes.

Admin uses primary key of an organization or other entities as the 
db.auth_group.role name. This makes it effortless to manage permissions for 
hundreds of user organizations and entities.

If a user organization was allowed to create an integer-named 
db.auth_group.role like "54", then sometime in the future, there might 
another organization whose primary key is "54" and permissions for that org 
cannot be created.

Integer can be tested for outside of the create-record and edit-a-record 
mode using all kinds of python features. So I could create a separate 
function just to test for integer then copy that var as default value to 
the creating/editing a record input form. That is a little extra work, but 
you're right, it's better than the try/except method.

It would be simpler to test for integer in the create/edit mode with a 
"requires =" clause. But I can't figure out how Python detect-integer 
functions can be written as "requires =" clauses.

Something like this would be good:

db.auth_group.role.requires = not IS_INT_IN_RANGE(-sys.maxint -1, 
sys.maxint)

thanks,

Alex

-- 
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.

Reply via email to