Submit `object_query` to MemberSuite, returning
    .models.MemberSuiteObjects.

    So this is a converter from MSQL to .models.MemberSuiteObjects.

    Returns query results as a list of MemberSuiteObjects.
509929
def submit_msql_object_query(object_query, client=None):
    
    client = client or get_new_client()
    if not client.session_id:
        client.request_session()

    result = client.execute_object_query(object_query)
    execute_msql_result = result["body"]["ExecuteMSQLResult"]

    membersuite_object_list = []

    if execute_msql_result["Success"]:

        result_value = execute_msql_result["ResultValue"]

        if result_value["ObjectSearchResult"]["Objects"]:
            # Multiple results.
            membersuite_object_list = []
            for obj in (result_value["ObjectSearchResult"]["Objects"]
                        ["MemberSuiteObject"]):
                membersuite_object = membersuite_object_factory(obj)
                membersuite_object_list.append(membersuite_object)
        elif result_value["SingleObject"]["ClassType"]:
            # Only one result.
            membersuite_object = membersuite_object_factory(
                execute_msql_result["ResultValue"]["SingleObject"])
            membersuite_object_list.append(membersuite_object)
        elif (result_value["ObjectSearchResult"]["Objects"] is None and
              result_value["SingleObject"]["ClassType"] is None):
            raise NoResultsError(result=execute_msql_result)

        return membersuite_object_list

    else:
        # @TODO Fix - exposing only the first of possibly many errors here.
        raise ExecuteMSQLError(result=execute_msql_result)
1068551
def object_list(self):
        

        def _sort(ob, ol):
            reverse = ob.startswith("-")
            ob = ob[1:] if reverse else ob
            for column in self.columns:
                if column.sort_key_fn is not None and column.name == ob:
                    return sorted(ol, key=column.sort_key_fn, reverse=reverse)
            if self._meta.order_by and hasattr(ol, "order_by"):
                return list(ol.order_by(*self._meta.order_by.split("|")))
            return ol

        ol = self._object_list
        ob = self._meta.order_by
        if not ob: return ol
        if isinstance(ob, basestring):
            return _sort(ob, ol)
        elif isinstance(ob, list):
            ob.reverse()
            for fn in ob:
                ol = _sort(fn, ol)
        return ol
314244
static List<JmxData> query(ObjectName query) throws Exception {
    return query(ManagementFactory.getPlatformMBeanServer(), query);
  }
559314
def list(self,table, **kparams):
        
        result = self.table_api_get(table, **kparams)
        return self.to_records(result, table)
1024614
def _build_models_query(self, query):
        
        registered_models_ct = self.build_models_list()
        if registered_models_ct:
            restrictions = [xapian.Query('%s%s' % (TERM_PREFIXES[DJANGO_CT], model_ct))
                            for model_ct in registered_models_ct]
            limit_query = xapian.Query(xapian.Query.OP_OR, restrictions)

            query = xapian.Query(xapian.Query.OP_AND, query, limit_query)

        return query
201805
def type_and_model_to_query(self, request):
        
        try:
            content_type_id = request.GET["content_type_id"]
            object_id = request.GET["object_id"]
        except KeyError:
            return HttpResponseBadRequest()

        try:
            content_type = ContentType.objects.get(pk=content_type_id)
            model = content_type.model_class()
            result = model.objects.get(pk=object_id)
        except ObjectDoesNotExist:
            data = ""
        else:
            data = '%s: "%d: %s"' % (content_type.model, result.pk, result)

        return JsonResponse({"query": data})
916414
def in_(self, *objs):
        
        if not objs:
            return self.table.c[self.fielda]!=self.table.c[self.fielda]
        else:
            keys = get_objs_columns(objs, self.reference_fieldname)
            sub_query = select([self.table.c[self.fielda]], (self.table.c[self.fieldb] == self.reference_class.c[self.reference_fieldname]) & (self.table.c[self.fieldb].in_(keys)))
            condition = self.model_class.c[self.reversed_fieldname].in_(sub_query)
            return condition
29397
public function get()
    {
        $queryset = $this->_filterOrExclude(
            false,
            static::formatConditions(__METHOD__, func_get_args())
        );

        $resultCount = count($queryset);

        if (1 == $resultCount) {
            return $queryset->getResults()[0];
        } elseif (!$resultCount) {
            throw new ObjectDoesNotExist(
                sprintf(
                    '%s matching query does not exist.',
                    $this->model->getMeta()->getNSModelName()
                )
            );
        }

        throw new MultipleObjectsReturned(
            sprintf(
                '"get() returned more than one %s -- it returned %s!"',
                $this->model->getMeta()->getNSModelName(),
                $resultCount
            )
        );
    }
118869
def objectlist(self, event):
        """"""

        self.log('LEGACY LIST FUNCTION CALLED!', lvl=warn)
        try:
            data, schema, user, client = self._get_args(event)
        except AttributeError:
            return

        object_filter = self._get_filter(event)
        self.log('Object list for', schema, 'requested from',
                 user.account.name, lvl=debug)

        if 'fields' in data:
            fields = data['fields']
        else:
            fields = []

        object_list = []

        opts = schemastore[schema].get('options', {})
        hidden = opts.get('hidden', [])

        if objectmodels[schema].count(object_filter) > WARNSIZE:
            self.log("Getting a very long list of items for ", schema,
                     lvl=warn)

        try:
            for item in objectmodels[schema].find(object_filter):
                try:
                    if not self._check_permissions(user, 'list', item):
                        continue
                    if fields in ('*', ['*']):
                        item_fields = item.serializablefields()
                        for field in hidden:
                            item_fields.pop(field, None)
                        object_list.append(item_fields)
                    else:
                        list_item = {'uuid': item.uuid}

                        if 'name' in item._fields:
                            list_item['name'] = item._fields['name']

                        for field in fields:
                            if field in item._fields and field not in hidden:
                                list_item[field] = item._fields[field]
                            else:
                                list_item[field] = None

                        object_list.append(list_item)
                except Exception as e:
                    self.log("Faulty object or field: ", e, type(e),
                             item._fields, fields, lvl=error, exc=True)
        except ValidationError as e:
            self.log('Invalid object in database encountered!', e, exc=True,
                     lvl=warn)
        # self.log("Generated object list: ", object_list)

        result = {
            'component': 'hfos.events.objectmanager',
            'action': 'getlist',
            'data': {
                'schema': schema,
                'list': object_list
            }
        }

        self._respond(None, result, event)
581853
def model_to_list(model_class, filter_dict=None, order_by_list=None,
                  select_related_fields=None, q_filter=None,
                  values=None,
                  to_json_method='to_json'):
    
    return model_to_page_list(model_class, page_num=None,
                              filter_dict=filter_dict, order_by_list=order_by_list,
                              select_related_fields=select_related_fields,
                              q_filter=q_filter, values=values,
                              to_json_method=to_json_method)
93394
def listSubjects(
        self, query, status=None, start=None, count=None, vendorSpecific=None
    ):
        
        response = self.listSubjectsResponse(
            query, status, start, count, vendorSpecific
        )
        return self._read_dataone_type_response(response, 'SubjectInfo')
325204
def get_objects(self, subject=None, predicate=None):
        """"""

        # Get the result of the search
        results = self.rdf.objects(subject, predicate)
        return list(results)
1130276
def to_representation(self, obj):
        
        kwargs = None
        for field in self.lookup_fields:
            if hasattr(obj, field):
                kwargs = {field: getattr(obj, field)}
                break
        if kwargs is None:
            raise AttributeError('Related object does not have any of lookup_fields')
        request = self._get_request()
        return request.build_absolute_uri(reverse(self._get_url(obj), kwargs=kwargs))
833762
async def object_resolver(self, object_name, fields, obey_auth=False, current_user=None, **filters):
        

        try:
            # check if an object with that name has been registered
            registered = [model for model in self._external_service_data['models'] \
                                if model['name']==object_name][0]
        # if there is no connection data yet
        except AttributeError:
            raise ValueError("No objects are registered with this schema yet.")
        # if we dont recognize the model that was requested
        except IndexError:
            raise ValueError("Cannot query for object {} on this service.".format(object_name))

        # the valid fields for this object
        valid_fields = [field['name'] for field in registered['fields']]

        # figure out if any invalid fields were requested
        invalid_fields = [field for field in fields if field not in valid_fields]
        try:
            # make sure we never treat pk as invalid
            invalid_fields.remove('pk')
        # if they weren't asking for pk as a field
        except ValueError:
            pass

        # if there were
        if invalid_fields:
            # yell loudly
            raise ValueError("Cannot query for fields {!r} on {}".format(
                invalid_fields, registered['name']
            ))

        # make sure we include the id in the request
        fields.append('pk')

        # the query for model records
        query = query_for_model(fields, **filters)

        # the action type for the question
        action_type = get_crud_action('read', object_name)

        # query the appropriate stream for the information
        response = await self.event_broker.ask(
            action_type=action_type,
            payload=query
        )

        # treat the reply like a json object
        response_data = json.loads(response)

        # if something went wrong
        if 'errors' in response_data and response_data['errors']:
            # return an empty response
            raise ValueError(','.join(response_data['errors']))

        # grab the valid list of matches
        result = response_data['data'][root_query()]

        # grab the auth handler for the object
        auth_criteria = self.auth_criteria.get(object_name)

        # if we care about auth requirements and there is one for this object
        if obey_auth and auth_criteria:

            # build a second list of authorized entries
            authorized_results = []

            # for each query result
            for query_result in result:
                # create a graph entity for the model
                graph_entity = GraphEntity(self, model_type=object_name, id=query_result['pk'])
                # if the auth handler passes
                if await auth_criteria(model=graph_entity, user_id=current_user):
                    # add the result to the final list
                    authorized_results.append(query_result)

            # overwrite the query result
            result = authorized_results

        # apply the auth handler to the result
        return result
971080
def getmembers(_object, _predicate):
    """"""
    # This should be:
    #return inspect.getmembers(_object, _predicate)

    # ... and it is re-implemented as:
    observers = []
    for key in dir(_object):
        try: m = getattr(_object, key)
        except AttributeError: continue
        if _predicate(m): observers.append((key, m))
        pass
    return observers
196914
def read_members_of(self, member_id, query_membership=None):
        
        route_values = {}
        if member_id is not None:
            route_values['memberId'] = self._serialize.url('member_id', member_id, 'str')
        query_parameters = {}
        if query_membership is not None:
            query_parameters['queryMembership'] = self._serialize.query('query_membership', query_membership, 'str')
        response = self._send(http_method='GET',
                              location_id='22865b02-9e4a-479e-9e18-e35b8803b8a0',
                              version='5.0-preview.1',
                              route_values=route_values,
                              query_parameters=query_parameters)
        return self._deserialize('[str]', self._unwrap_collection(response))
1275821
def get_objects_with_object(self, obj_type, *child_types):
        

        return [o for o in self.get_objects_by_type(obj_type) if
                o.get_objects_by_type(*child_types)]