django-hashid-field icon indicating copy to clipboard operation
django-hashid-field copied to clipboard

Include internal hashid state into the picking state

Open svartalf opened this issue 3 years ago • 2 comments
trafficstars

I hit the same issue as in #55 with django-cacheops and django-hashid-field.

Unfortunately for me, that enable_hashid_object=False "workaround" can't be applied in my case, but I've found that if you include self._hashids attribute into the pickled state, hashid objects can be successfully deserialized from the cache provided by django-cacheops. As a side thought: the actual fix might be that some other attribute is now excluded from the pickled representation, but I'm not exactly sure what else can affect this behavior in here.

Please note that this is a breaking change as it changes pickling behavior.

svartalf avatar Aug 19 '22 14:08 svartalf

My apologies, I'm converting it back to draft to ensure that this change works correctly

svartalf avatar Aug 22 '22 13:08 svartalf

Just a note that I haven't missed or forgotten this, just haven't had time to do a deep dive into what's going on with django-cacheops. However, pickling the _hashids object (which is an instance of the Hashids library object) doesn't have the right smell. But I could be wrong. Won't know until I have some time to dedicated to this. Hopefully soon.

nshafer avatar Aug 31 '22 16:08 nshafer

I have merged this in, and tested the behavior of unpickling old pickled objects, and it looks like it's fully backwards compatible. So unpickling should no longer need to recompute the hashid. Sorry for the delay.

nshafer avatar Oct 11 '22 22:10 nshafer