Hey, I need help with setting up an authentication code. I am currently working on a project to build a blog server in python for an intro level python course. We are using the PESTO and POSTGRESQL wsgi and sql clients respectively. I am trying to authenticate against a user name and password in the database and myself and I suspect my partner are becoming incredibly frustrated with the lack of progress being made. If we could get the authentication script working, everything else would fall into place.
import time, os import pesto import logging #import pgdb os.environ['PATH'] +=";C:\\Program Files (x86)\\PostgreSQL\\8.4\\bin" #input the directory of your postgreSQL database program. import pgdb dispatcher = pesto.dispatcher_app() """ Use this as necessary, if the database has already been loaded in another module, this can be excised. At the current moment, we just want to get the authentication module working. Otherwise, we won't need to worry about this particular strip of code. All we need is the authentication. """ def getConnection(self): try: connection = pgdb.connect( host="localhost:5432", database="project1", user="postgres", password="p0stgr3sq1") cursor = connection.cursor() except: # TODO: log print 'Error connecting to database > ' print sys.exc_value return -1 request.session['username'] = request.get('username') request.session['password'] = request.get('password') username = request.session['username'] # Switch to request.get as required. password = request.session['password'] # Switch to request.get as required. #datapull will call the data from a database query from the login procedure. #It will compare the user input to @dispatcher.match('/auth', 'POST') def datapull (username, password): cursor.execute('select %s from users') % username dbname = dbcur.fetchone() if dbname == username: cursor.execute('select %s from password') % password dbpass = dbcur.fetchone() if dbpass == password(): dbpass = dbcur.fetchone() pesto.response.redirect('/admin-entry', 'POST') else: return "Password is invalid or does not exist." logging.error("Invalid Password Input.") else: return "We are sorry, there is no user matching that name in our database." logging.error("Invalid user name.")
When we try to input the stuff into 'pulldata', it throws an error regarding the use of tokens in the command line. Any help would be greatly appreciated. If I could just get this to work, that would be fantastic.