def no_loops_in_hierarchy(key, data, errors, context):
 if (not ('id' in data)):
  return
 group = context['model'].Group.get(data['id'])
 allowable_parents = group.groups_allowed_to_be_its_parent(type=group.type)
 for parent in data['groups']:
  parent_name = parent['name']
  if (parent_name and (context['model'].Group.get(parent_name) not in allowable_parents)):
   raise Invalid(_('This parent would create a loop in the hierarchy'))

def no_loops_in_hierarchy ( key , data , errors , context ) : if ( not ( 'id' in data ) ) : return group = context [ 'model' ] . Group . get ( data [ 'id' ] ) allowable_parents = group . groups_allowed_to_be_its_parent ( type = group . type ) for parent in data [ 'groups' ] : parent_name = parent [ 'name' ] if ( parent_name and ( context [ 'model' ] . Group . get ( parent_name ) not in allowable_parents ) ) : raise Invalid ( _ ( 'This parent would create a loop in the hierarchy' ) )
checks that the parent groups specified in the data would not cause a loop in the group hierarchy .