def member_create(context, data_dict=None):
 model = context['model']
 user = context['user']
 rev = model.repo.new_revision()
 rev.author = user
 if ('message' in context):
  rev.message = context['message']
 else:
  rev.message = (_(u'REST API: Create member object %s') % data_dict.get('name', ''))
 (group_id, obj_id, obj_type, capacity) = _get_or_bust(data_dict, ['id', 'object', 'object_type', 'capacity'])
 group = model.Group.get(group_id)
 if (not group):
  raise NotFound('Group was not found.')
 obj_class = ckan.logic.model_name_to_class(model, obj_type)
 obj = obj_class.get(obj_id)
 if (not obj):
  raise NotFound(('%s was not found.' % obj_type.title()))
 _check_access('member_create', context, data_dict)
 member = model.Session.query(model.Member).filter((model.Member.table_name == obj_type)).filter((model.Member.table_id == obj.id)).filter((model.Member.group_id == group.id)).filter((model.Member.state == 'active')).first()
 if (not member):
  member = model.Member(table_name=obj_type, table_id=obj.id, group_id=group.id, state='active')
 member.capacity = capacity
 model.Session.add(member)
 model.repo.commit()
 return model_dictize.member_dictize(member, context)

def member_create ( context , data_dict = None ) : model = context [ 'model' ] user = context [ 'user' ] rev = model . repo . new_revision ( ) rev . author = user if ( 'message' in context ) : rev . message = context [ 'message' ] else : rev . message = ( _ ( u'REST API: Create member object %s' ) % data_dict . get ( 'name' , '' ) ) ( group_id , obj_id , obj_type , capacity ) = _get_or_bust ( data_dict , [ 'id' , 'object' , 'object_type' , 'capacity' ] ) group = model . Group . get ( group_id ) if ( not group ) : raise NotFound ( 'Group was not found.' ) obj_class = ckan . logic . model_name_to_class ( model , obj_type ) obj = obj_class . get ( obj_id ) if ( not obj ) : raise NotFound ( ( '%s was not found.' % obj_type . title ( ) ) ) _check_access ( 'member_create' , context , data_dict ) member = model . Session . query ( model . Member ) . filter ( ( model . Member . table_name == obj_type ) ) . filter ( ( model . Member . table_id == obj . id ) ) . filter ( ( model . Member . group_id == group . id ) ) . filter ( ( model . Member . state == 'active' ) ) . first ( ) if ( not member ) : member = model . Member ( table_name = obj_type , table_id = obj . id , group_id = group . id , state = 'active' ) member . capacity = capacity model . Session . add ( member ) model . repo . commit ( ) return model_dictize . member_dictize ( member , context )
create a load balance member .