Exemplo n.º 1
0
Arquivo: index.py Projeto: ab/blag
def login_author(author_name,pwd):
    token = db.login(author_name,pwd)
    if token is not False:
        author = db.get_author(author_name)
        cherrypy.response.cookie["session_token"] = token
        cherrypy.response.cookie["author_id"] = author["id"]
        return author
    return False
Exemplo n.º 2
0
def display_books_by_author():
    author_id = int(input("Author ID: "))
    author = db.get_author(author_id)
    if author is None:
        print("There is no author with that ID.\n")
    else:
        print()
        books = db.search_book_by_author(author_id)
        display_books(books, author.name.upper())
Exemplo n.º 3
0
Arquivo: index.py Projeto: ab/blag
 def register(self, author_name=None, password=None, confirm=None,
              submit=None):
     if cherrypy.request.method.lower() != "post":
         return {}
     if author_name is None or password is None:
         return {"message":
                     "You must specify both author name and password."}
     elif db.get_author(author_name) is not None:
         return {"message":"That author already exists."}
     elif password != confirm:
         return {"message":"Passwords did not match."}
     db.add_author(author_name, password)
     login_author(author_name,password)
     raise cherrypy.HTTPRedirect("/")
Exemplo n.º 4
0
Arquivo: index.py Projeto: ab/blag
def dereference_author(post):
    d = dict(post)
    d["author"] = db.get_author(post["author_id"])
    return d