Working on a project site with user creation/login this morning. The code was working fine on localhost. I pushed the code to my heroku account and left for the day. This evening I returned home and began testing the site. I was getting an exception I was not prepared for. Started up localhost and recreated the issue which is TypeError: '_PasslibRegistryProxy' object is not callable and now I have no clue how to resolve it. It would appear that in the process of git adding, committing and pushing, I broke my passlib files. Yet, I have done no editing of the source code for passlib. In addition, I recreated the error with minimal code in an entirely new workspace. New harddrive entirely, new folder, ran pip install passlib -t . (forces installation into that directory). I ran the following 3 lines of code and continued to receive the same error:
import passlib.hash
a = passlib.hash('magic15!')
print(a)
In my primary workspace, I attempted pip install passlib --upgrade -t . and that didn't resolve my issue. And I'm using passlib.hash() rather than the sha256_encrypt() due to the deprecated message.
I'm completely befuddled because this was working fine and I've done no changes to that code other than attempting to resolve it.
How passlib.hash() ever worked is beyond me still at this point. However, it is best that it failed and spurred this question. The answer came from the Python discord server (Thank you Scott and XX) and is a reminder to go back to the original documentation, don't always lean on tutorial videos which can become outdated.
The documentation for passlib never declares that using
passlib.hash()in the manner that I did should work. Instead, at the time of writing this response, the code should be as follows:For anyone else who comes across this error, confirm you're using the correct code based on the most updated documentation:
https://passlib.readthedocs.io/en/stable/narr/hash-tutorial.html
Though I suggest reading this article as well: https://passlib.readthedocs.io/en/stable/narr/quickstart.html#recommended-hashes
To clarify why I was using the incorrect code, I had received
I received this while using sha256_crypt.encrypt() as taught via a tutorial video series. Using passlib.hash() was working and suddenly stopped. I guess for the better but the fact that it was working and stopped, that confused the tar out of me. However, realigning with the documentation is a far more appropriate direction to continue in.