I've really gotta start proofreading my responses. This is a better version 
that the one I just gave (goes at the bottom of the model):

def pineapple_insert(**kwargs):
    if db(db.pineapple.owner == auth.user.id).count() >= 3:
        raise Exception('There are already 3 pineapples for this user.')
    else:
        db.pineapple.insert(**kwargs)

db.pineapple_insert = pineapple_insert

The last line attaches the method to the db object so that it can be used in 
all controllers. If you are looking use this in conjunction with SQLFORM or 
something, then you would also want to do what pbreit said and check into 
custom validators.

Reply via email to