def get_groups(request): group_names_str = request.GET.get('group_names') or request.POST.get('group_names') group_ids_str = request.GET.get('group_ids') or request.POST.get('group_ids') group_names = [] group_ids = [] if group_names_str: logger.debug("group_names_str: %s" % group_names_str) group_names = group_names_str.split(',') elif group_ids_str: logger.debug("group_ids_str: %s" % group_names_str) group_ids = group_ids_str.split(',') else: #XXX TODO maybe raise invalid request response logger.warning("group_names_str or group_ids_str not set") raise Http404 #groups = Group.objects.filter(name__in=group_names) groups = get_groups(group_ids=group_ids, group_names=group_names) return HttpResponse(json_serializer.serialize(groups, indent=2, use_natural_keys=True))
def get_groups(request): group_names_str = request.GET.get('group_names') or request.POST.get( 'group_names') group_ids_str = request.GET.get('group_ids') or request.POST.get( 'group_ids') group_names = [] group_ids = [] if group_names_str: logger.debug("group_names_str: %s" % group_names_str) group_names = group_names_str.split(',') elif group_ids_str: logger.debug("group_ids_str: %s" % group_names_str) group_ids = group_ids_str.split(',') else: #XXX TODO maybe raise invalid request response logger.warning("group_names_str or group_ids_str not set") raise Http404 #groups = Group.objects.filter(name__in=group_names) groups = get_groups(group_ids=group_ids, group_names=group_names) return HttpResponse( json_serializer.serialize(groups, indent=2, use_natural_keys=True))
def get_content_object(self, py_serialized_content): """Deserialize dict of content fields to a content object. py_serialized_content is the deserialized python struct { 'pk': 6, 'model': 'treeauth.localuser', 'fields': { 'user': 7, 'groups': [1, 3] } } """ logger.debug("LocalUserDeserializerUtil") logger.debug("py_serialized_content: " + str(py_serialized_content)) fields = py_serialized_content['fields'] # for some reasone returned as a list?? #user_id = fields['user'] username = fields['user'][0] group_names = [] # groups returned as list of lists probably as many-to-many for grp in fields['groups']: # for some reason list of lists?? group_names.append(grp[0]) logger.debug("username: "******"group_names: " + str(group_names)) user = get_user(username=username) logger.debug("got user: "******"got groups: " + str(type(groups))) local_user = LocalUserProxy(user, groups) logger.debug("created local_user instance: " + str(local_user)) return local_user
def get_content_object(self, py_serialized_content): """Deserialize dict of content fields to a content object. py_serialized_content is the deserialized python struct { 'pk': 6, 'model': 'treeauth.localuser', 'fields': { 'user': 7, 'groups': [1, 3] } } """ logger.debug("LocalUserDeserializerUtil") logger.debug("py_serialized_content: " + str(py_serialized_content) ) fields = py_serialized_content['fields'] # for some reasone returned as a list?? #user_id = fields['user'] username = fields['user'][0] group_names = [] # groups returned as list of lists probably as many-to-many for grp in fields['groups']: # for some reason list of lists?? group_names.append(grp[0]) logger.debug("username: "******"group_names: " + str(group_names)) user = get_user(username=username) logger.debug("got user: "******"got groups: " + str(type(groups))) local_user = LocalUserProxy(user, groups) logger.debug("created local_user instance: " + str(local_user)) return local_user