Luke Plant avatar Luke Plant committed 5abd9b1

Consistent naming for functions

Comments (0)

Files changed (1)

lukeplant_me_uk/bibleverses/web/cgi-bin/lib/bibleverses/views.py

-import simplejson 
+import simplejson
 from urllib import unquote
 from bibleverses.webutils import HttpResponse, dispatch
 from bibleverses import db
             return None
     retrieve = staticmethod(retrieve)
 
-    def checkPassword(self, password):
+    def check_password(self, password):
         return self.password == password
 
     def get_verses(self):
-        return [row[0] for row in 
+        return [row[0] for row in
                 db.execute("SELECT verseref FROM verses WHERE userid = %s ORDER BY verseref;", self.id)]
 
     def add_verse(self, verseref):
         if len(db.execute("SELECT id FROM verses WHERE verseref = %s AND userid = %s;", verseref, self.id)) == 0:
             db.execute("INSERT INTO verses (id, userid, verseref) VALUES (NULL, %s, %s);", self.id, verseref)
 
-    def delete_verse(self, verseref):
+    def remove_verse(self, verseref):
         db.execute("DELETE FROM verses WHERE verseref = %s AND userid = %s;", verseref, self.id)
 
 ##### View functions ####
 
-def register(request):         
+def register(request):
     email = request.POST.get('email', '').strip()
     password = request.POST.get('password', '').strip()
     if len(email) == 0:
 
     user = User.retrieve(email)
     if user is not None:
-        if user.checkPassword(password):
+        if user.check_password(password):
             return success()
         else:
             return failure(validation=[MSG_PASSWORD_INCORRECT, "Password is incorrect."])
     email =  unquote(request.get_cookie('email', ''))
     password = unquote(request.get_cookie('password',''))
     u = User.retrieve(email)
-    if u is not None and u.checkPassword(password):
+    if u is not None and u.check_password(password):
         return u
-    else: 
+    else:
         return None
 
 def verses(request):
     return success(verselist=request.user.get_verses())
 verses = require_user(verses)
 
-def addverse(request):
+def add_verse(request):
     verseref = request.POST.get('verse')
     if verseref is None or verseref == '':
         return failure()
     request.user.add_verse(verseref)
     return success(verse=verseref)
-addverse = require_user(addverse)
+add_verse = require_user(add_verse)
 
-def removeverse(request):
+def remove_verse(request):
     verseref = request.POST.get('verse')
     if verseref is None or verseref == '':
         return failure()
-    request.user.delete_verse(verseref)
+    request.user.remove_verse(verseref)
     return success(verse=verseref)
-removeverse = require_user(removeverse)
+remove_verse = require_user(remove_verse)
 
 ##### Database creation/upgrade #####
 
-def initdb(request):
+def init_db(request):
     db.execute("""
 CREATE TABLE users (
        id integer PRIMARY KEY,
 """)
     return success()
 
-def dropdb(request):
+def drop_db(request):
     db.execute("""
 DROP TABLE users;
 DROP TABLE verses;
 COOKIES:
 %r
 
-Environ: 
-%r 
+Environ:
+%r
 
-""" % (req.method, req.path, req.GET, req.POST, req.COOKIES, req.environ), 
+""" % (req.method, req.path, req.GET, req.POST, req.COOKIES, req.environ),
                         content_type="text/plain")
 
 
     ('^/register/$',    register),
     ('^/login/$',       login),
     ('^/verses/$',      verses),
-    ('^/addverse/$',    addverse),
-    ('^/removeverse/$', removeverse),
+    ('^/addverse/$',    add_verse),
+    ('^/removeverse/$', remove_verse),
     ('^/debug/$',       debug),
-#    ('^/initdb/$',      initdb),
-#    ('^/dropdb/$',      dropdb),
+#    ('^/initdb/$',      init_db),
+#    ('^/dropdb/$',      drop_db),
 #    ('^/upgrade1/$',    upgrade1),
 ]
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.