@classmethod
def get_or_create(cls, store, **kwargs):
    """Get the object from the database that matches the given criteria, and if
        it doesn't exist, create a new object, with the properties given already
        set.

        The properties given ideally should be the primary key, or a candidate
        key (unique values).

        :returns: an object matching the query or a newly created one if a
          matching one couldn't be found.
        """
    obj = store.find(cls, **kwargs).one()
    if obj is not None:
        return obj
    obj = cls(store=store)
    for key, value in kwargs.items():
        setattr(obj, key, value)
    return obj
