Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include internal hashid state into the picking state #71

Merged
merged 2 commits into from
Oct 11, 2022

Conversation

svartalf
Copy link
Contributor

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 svartalf marked this pull request as draft August 22, 2022 13:51
@svartalf
Copy link
Contributor Author

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

Python gives it more priority instead of __getstate__/__setstate__ methods
@svartalf svartalf marked this pull request as ready for review August 22, 2022 14:00
@nshafer
Copy link
Owner

nshafer commented Aug 31, 2022

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 nshafer merged commit b6af265 into nshafer:master Oct 11, 2022
@nshafer
Copy link
Owner

nshafer commented Oct 11, 2022

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants