def pr_rebuild_path(pe_id, clear=False):
 if isinstance(pe_id, Row):
  pe_id = pe_id.pe_id
 rtable = current.s3db.pr_role
 query = (((rtable.pe_id == pe_id) & (rtable.role_type == OU)) & (rtable.deleted != True))
 db = current.db
 db(query).update(path=None)
 roles = db(query).select(rtable.id, rtable.pe_id, rtable.path, rtable.role_type)
 for role in roles:
  if (role.path is None):
   pr_role_rebuild_path(role, clear=clear)

def pr_rebuild_path ( pe_id , clear = False ) : if isinstance ( pe_id , Row ) : pe_id = pe_id . pe_id rtable = current . s3db . pr_role query = ( ( ( rtable . pe_id == pe_id ) & ( rtable . role_type == OU ) ) & ( rtable . deleted != True ) ) db = current . db db ( query ) . update ( path = None ) roles = db ( query ) . select ( rtable . id , rtable . pe_id , rtable . path , rtable . role_type ) for role in roles : if ( role . path is None ) : pr_role_rebuild_path ( role , clear = clear )
rebuild the ancestor path of all roles in the ou hierarchy a person entity defines .