I have a model that looks somewhat like this

db.define_table('topic_teacher',
                Field('skill', 'list:string', required=True),
                Field('description', 'text', required=True),
                Field('topic', 'reference topic'),
                Field('teacher', 'reference auth_user'),
db.topic_teacher.topic.writable = False
db.topic_teacher.topic.readable = False
db.topic_teacher.teacher.writable = False
db.topic_teacher.teacher.readable = False



where I need the combination of topic and teacher to be unique so one 
person can register as a teacher for a certain topic only one time.

Skill and description are filled in using SQLFORM and topic and teacher 
using
form.vars.topic = topic_id #(from request.args)
form.vars.teacher = teacher_id #(from auth.user.id)


My first try was to add a computed field to the table representing a 
combination of topic and teacher and using  unique=True on it which doesn't 
work. I still can happily insert records containing the same teacher id and 
topic id using the form and the computed field will happily accept same 
values in the db.

Now before I try doing weird requires= magic with the computed field, is 
there an established best way to accomplish what I'm trying to do?

Thanks in advance.

-- 
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].
For more options, visit https://groups.google.com/d/optout.

Reply via email to