'get(id, owner=None, type=None) -> SavedQuery object
Checks that the owner and type match (when given).
May raise PopupException (type/owner mismatch).
May raise SavedQuery.DoesNotExist.'

@staticmethod
def get(id, owner=None, type=None):

    try:
        design = SavedQuery.objects.get(id=id)
    except SavedQuery.DoesNotExist as err:
        msg = (_('Cannot    retrieve    query    id    %(id)s.') % {'id': id})
        raise err
    if ((owner is not None) and (design.owner != owner)):
        msg = (_('Query    id    %(id)s    does    not    belong    to    user    %(user)s.') % {'id': id, 'user': owner})
        LOG.error(msg)
        raise PopupException(msg)
    if ((type is not None) and (design.type != type)):
        msg = (_('Type    mismatch    for    design    id    %(id)s    (owner    %(owner)s)    -    Expected    %(expected_type)s,    got    %(real_type)s.') % {'id': id, 'owner': owner, 'expected_type': design.type, 'real_type': type})
        LOG.error(msg)
        raise PopupException(msg)
    return design
