'Return objects having attributes with the given key, category,
value, strvalue or combination of those criteria.
Args:
key (str, optional): The attribute\'s key to search for
category (str, optional): The category of the attribute
to search for.
value (str, optional): The attribute value to search for.
Note that this is not a very efficient operation since it
will query for a pickled entity. Mutually exclusive to
`strvalue`.
strvalue (str, optional): The str-value to search for.
Most Attributes will not have strvalue set. This is
mutually exclusive to the `value` keyword and will take
precedence if given.
attrype (str, optional): An attribute-type to search for.
By default this is either `None` (normal Attributes) or
`"nick"`.
Returns:
obj (list): Objects having the matching Attributes.'

@returns_typeclass_list
def get_by_attribute(self, key=None, category=None, value=None, strvalue=None, attrtype=None):

    dbmodel = self.model.__dbclass__.__name__.lower()
    query = [('db_attributes__db_attrtype', attrtype), ('db_attributes__db_model', dbmodel)]
    if key:
        query.append(('db_attributes__db_key', key))
    if category:
        query.append(('db_attributes__db_category', category))
    if strvalue:
        query.append(('db_attributes__db_strvalue', strvalue))
    elif value:
        query.append(('db_attributes__db_value', value))
    return self.filter(**dict(query))
