I can't say I've ever really tried this, but maybe you could do something 
like this in your model:

db.pineapple_insert(**kwargs):
    if db(db.pineapple.id > 0).count() >= 3:
        raise Exception('There are already 3 pineapples in this table.')
    else:
        db.pineapple.insert(**kwargs)

Then instead of calling db.pineapple.insert() in your controllers, you would 
call db.pineapple_insert() <--- Notice the underscore instead of the dot. 
This function is just a wrapper around DAL's insert() method, but does the 
checking before actually calling the insert() method.

Reply via email to