I'd like to avoid having duplicate memberships to the auth_membership
table. Based on an earlier thread (http://groups.google.com/group/
web2py/browse_thread/thread/133644f67efdc217/69f25bb658d85310), I
thought that adding a requires statement to the db.py model definition
would do it, but it doesn't seem to. The table definition is the same
as the standard one, and then I tried to add a requirement for the
'id' field, but it doesn't seem to have any effect. What am I doing
wrong?
auth.settings.table_membership = db.define_table(
auth.settings.table_membership_name, ## this setting is
"auth_membership"
db.Field('user_id', auth.settings.table_user,
requires=IS_IN_DB(db,'%s.id'%auth.settings.table_user_name,
'%(id)s: %(first_name)s %(last_name)s')),
db.Field('group_id', auth.settings.table_group,
requires=IS_IN_DB(db,'%s.id'%auth.settings.table_group_name,
'%(id)s: %(role)s'))
)
auth.settings.table_membership.id.requires=IS_NOT_IN_DB(
db((auth.settings.table_membership.user_id==request.vars.user_id)&
(auth.settings.table_membership.group_id==request.vars.group_id)),
'%s.id'%auth.settings.table_membership)
I am still able to add duplicate rows to the auth_membership table
without any errors.
Dan
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"web2py Web Framework" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---