@classmethod<EOL><INDENT>@has_storage<EOL>@log_storage<EOL>def load(cls, key=None, data=None, _is_loaded=True):<DEDENT>
<EOL>signals.load.send(<EOL>cls,<EOL>key=key,<EOL>data=data,<EOL>)<EOL>if key is not None:<EOL><INDENT>key = cls._check_pk_type(key)<EOL>cached_object = cls._load_from_cache(key)<EOL>if cached_object is not None:<EOL><INDENT>return cached_object<EOL><DEDENT><DEDENT>if data is None:<EOL><INDENT>data = cls._storage[<NUM_LIT:0>].get(cls._primary_name, cls._pk_to_storage(key))<EOL><DEDENT>if data is None:<EOL><INDENT>return None<EOL><DEDENT>data = cls.from_storage(data)<EOL>if cls._version_of and '<STR_LIT>' in data and data['<STR_LIT>'] != cls._version:<EOL><INDENT>old_object = cls._version_of.load(data=data)<EOL>new_object = cls(_is_loaded=_is_loaded)<EOL>cls.migrate(old_object, new_object)<EOL>new_object._stored_key = new_object._primary_key<EOL>return new_object<EOL><DEDENT>ret = cls(_is_loaded=_is_loaded, **data)<EOL>ret._stored_key = ret._primary_key<EOL>return ret<EOL>
Get a record by its primary key.