|
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. |
|
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! 1
seanf - you are the man!!!! this is exactly what i am looking for. best practice becomes best practice if everybody is doing it :) thank you so much - you made my week. |
|
If you do not want to write all of the database/user boilerplate you might want to use a framework like Django. By definition CherryPy is a minimalist framework and so you will have to write a lot of the boilerplate yourself. Thank you for your answer, johns. I had considered using Django a long time ago. My problem is this: I write python applications without really thinking about the web side of it first. So, what I need, is to keep the HTTP and HTTP related functionality (like authentication) separate. Django is nice and (pretty complete, it seems), but they force you to use their standards. Last I checked, I could not use SQLAlchemy, for example, because DJango has its own ORM. Maybe this has changed. Either way, although it provides a lot of ready made solutions for you, it is not for me. |