def set_activity_type_requires(tablename, sector_ids):
 attable = s3db.project_activity_type
 if sector_ids:
  atstable = s3db.project_activity_type_sector
  rows = db().select(attable.id, atstable.sector_id, left=atstable.on((attable.id == atstable.activity_type_id)))
  activity_type_ids = [row.project_activity_type.id for row in rows if ((not row.project_activity_type_sector.sector_id) or (row.project_activity_type_sector.sector_id in sector_ids))]
 else:
  activity_type_ids = []
 s3db[tablename].activity_type_id.requires = IS_EMPTY_OR(IS_ONE_OF(db, 'project_activity_type.id', s3base.S3Represent(lookup='project_activity_type'), filterby='id', filter_opts=activity_type_ids, sort=True))

def set_activity_type_requires ( tablename , sector_ids ) : attable = s3db . project_activity_type if sector_ids : atstable = s3db . project_activity_type_sector rows = db ( ) . select ( attable . id , atstable . sector_id , left = atstable . on ( ( attable . id == atstable . activity_type_id ) ) ) activity_type_ids = [ row . project_activity_type . id for row in rows if ( ( not row . project_activity_type_sector . sector_id ) or ( row . project_activity_type_sector . sector_id in sector_ids ) ) ] else : activity_type_ids = [ ] s3db [ tablename ] . activity_type_id . requires = IS_EMPTY_OR ( IS_ONE_OF ( db , 'project_activity_type.id' , s3base . S3Represent ( lookup = 'project_activity_type' ) , filterby = 'id' , filter_opts = activity_type_ids , sort = True ) )
filters the activity_type_id based on the sector_id .