hello all, I am learning CherryPy, and would like to have a simple cherrypy authentication against a MySQL database user table that stores a username and an MD5 hashed password string.
Is there a dead easy tutorial out there other than the example posted on the CherryPy wiki (http://tools.cherrypy.org/wiki/AuthenticationAndAccessRestrictions)?
I am coming from a PHP background, I do not know if that matters, but I am used to authentication schemes handled by server side PHP session objects. So, anything that can compare to that would be welcome, because it would help me relate. I decided to use CherryPy because it seems to be the framework that fit the bill. I have a couple of very simple python apps in the works and just need something to provide the HTTP handling. Alternatively, my other choice would be Web.py, but since CherryPy support is better with WebFaction, I thought I would go that route. In addition, if I understand my reading sufficiently, CherryPy will provide the robust framework I need.
Thanks in advance.
asked Feb 18 '12 at 13:03
There are some fairly simple examples of CherryPy authentication at: CherryPy Digest and Basic Authentication Tutorial
Here is the basic authentication example from that page, modified to work with MySQL as the source of user info:
I don't claim that the above code represents any sort of best-practice approach to doing this - just posting it as a simple example.
Hope that helps!
Unless you need some of the special things you can implement with CherryPy and you can't do with an out-of-the-box apache wsgi install, I wouldn't go through all the hassle. I can just second Johns suggestion to use django with mod-wsgi. However, if you still want to use CherryPy instead of apache you can use it together with django (or any other wsgi compliant python framework like turbogears 2x, pylons, etc.): http://docs.cherrypy.org/dev/refman/wsgiserver/init.html. If you want to use CherryPy the hard way, at least have a look at http://werkzeug.pocoo.org/