I have a model which has sites and servers with a many-to-many relation described by site_servers as follows:
# Global table of known sites db.define_table('sites', Field('uuid', 'string', length=64, default=str(uuid.uuid4()), writable=False), Field('last_modified', 'datetime', default=request.now, update=request.now, writable=False, readable=False), Field('name', 'string', length=16, required=True, notnull=True, unique=True, label='Site name'), Field('long_name', 'string', length=64, unique=True, label='Site full name'), format='%(name)s' ) # Global table of known servers db.define_table('servers', Field('uuid', 'string', length=64, default=str(uuid.uuid4()), writable=False), Field('last_modified', 'datetime', default=request.now, update=request.now, writable=False, readable=False), Field('hostname', 'string', length=64, required=True, notnull=True, unique=True, label='Hostname:'), format='%(hostname)s' ) # Global table showing which servers perform known functions for which sites. # The default is a server provides all services. db.define_table('site_servers', Field('uuid', 'string', length=64, default=str(uuid.uuid4()), writable=False), Field('last_modified', 'datetime', default=request.now, update=request.now, writable=False, readable=False), Field('site_uuid', 'string', length=64), Field('server_uuid', 'string', length=64), Field('web_server', 'boolean', default=True), Field('archiver', 'boolean', default=True) ) db.site_servers.site_uuid.requires = IS_IN_DB(db, 'sites.uuid', '% (name)s') db.site_servers.server_uuid.requires = IS_IN_DB(db, 'servers.uuid', '% (hostname)s') sites_and_servers = db((db.sites.uuid==db.site_servers.site_uuid) & (db.servers.uuid==db.site_servers.server_uuid)) The problem is this line that should be used to test for uniqueness of the site_servers rows so I don't get duplicate entries in the join table causes the server line of the site_servers insert form to change from a drop down selecting from existing servers to a text input line. # Test for uniqueness across site_uuid and server_uuid db.site_servers.server_uuid.requires = IS_NOT_IN_DB(db (db.site_servers.site_uuid==request.vars.site_uuid),db.site_servers.server_uuid) I took thie problem line from several other posts, however they were not involving uuid and timestamp tables meant for global use across multiple installations of the database. I have trimmed some fields from the model to simplify the definition. Also the example in the DAL chapter third edition of the book under the heading CSV and Remote Database Synchronization shows the 'modified_on' field setting of default=now which results in undefined variable now. I believe that should be default=request.now Thanks for any advice Ron