dddp/models.py
def get_object_ids(model, meteor_ids):
    """Return all object IDs for the given meteor_ids."""
    if model is ObjectMapping:
        # this doesn't make sense - raise TypeError
        raise TypeError("Can't map ObjectMapping instances through self.")
    # Django model._meta is now public API -> pylint: disable=W0212
    meta = model._meta
    alea_unique_fields = [
        field
        for field in meta.local_fields
        if isinstance(field, AleaIdField) and field.unique and not field.null
    ]
    result = collections.OrderedDict(
        (str(meteor_id), None)
        for meteor_id
        in meteor_ids
    )
    if len(alea_unique_fields) == 1:
        aid = alea_unique_fields[0].name
        query = model.objects.filter(**{
            '%s__in' % aid: meteor_ids,
        }).values_list(aid, 'pk')
    else:
        content_type = ContentType.objects.get_for_model(model)
        query = ObjectMapping.objects.filter(
                content_type=content_type,
                meteor_id__in=meteor_ids,
        ).values_list('meteor_id', 'object_id')
    for meteor_id, object_id in query:
        result[meteor_id] = object_id
    return result
def get_object_ids(model, meteor_ids):
    """Return all object IDs for the given meteor_ids."""
    if model is ObjectMapping:
        # this doesn't make sense - raise TypeError
        raise TypeError("Can't map ObjectMapping instances through self.")
    # Django model._meta is now public API -> pylint: disable=W0212
    meta = model._meta
    alea_unique_fields = [
        field
        for field in meta.local_fields
        if isinstance(field, AleaIdField) and field.unique and not field.null
    ]
    result = collections.OrderedDict(
        (str(meteor_id), None)
        for meteor_id
        in meteor_ids
    )
    if len(alea_unique_fields) == 1:
        aid = alea_unique_fields[0].name
        query = model.objects.filter(**{
            '%s__in' % aid: meteor_ids,
        }).values_list(aid, 'pk')
    else:
        content_type = ContentType.objects.get_for_model(model)
        query = ObjectMapping.objects.filter(
                content_type=content_type,
                meteor_id__in=meteor_ids,
        ).values_list('meteor_id', 'object_id')
    for meteor_id, object_id in query:
        result[meteor_id] = object_id
    return result
def get_object_ids ( model , meteor_ids ) : if model is ObjectMapping : # this doesn't make sense - raise TypeError raise TypeError ( "Can't map ObjectMapping instances through self." ) # Django model._meta is now public API -> pylint: disable=W0212 meta = model . _meta alea_unique_fields = [ field for field in meta . local_fields if isinstance ( field , AleaIdField ) and field . unique and not field . null ] result = collections . OrderedDict ( ( str ( meteor_id ) , None ) for meteor_id in meteor_ids ) if len ( alea_unique_fields ) == 1 : aid = alea_unique_fields [ 0 ] . name query = model . objects . filter ( * * { '%s__in' % aid : meteor_ids , } ) . values_list ( aid , 'pk' ) else : content_type = ContentType . objects . get_for_model ( model ) query = ObjectMapping . objects . filter ( content_type = content_type , meteor_id__in = meteor_ids , ) . values_list ( 'meteor_id' , 'object_id' ) for meteor_id , object_id in query : result [ meteor_id ] = object_id return result
Return all object IDs for the given meteor_ids.
Return all object IDs for the given meteor_ids .