Example #1
0
 def __init__(self, dbname):
     if sys.version < '3':
         from psycopg2.extensions import register_type, UNICODE
         register_type(UNICODE)
     self.dbconn = DbConnection(dbname)
     self.film = FilmHandler(self.dbconn)
     self.url_map = Map([
         Rule('/', endpoint='index'),
         Rule('/films', endpoint='film'),
         Rule('/film/<path:parts>', endpoint='film')
     ])
Example #2
0
class DatabaseApp(object):
    def __init__(self, dbname):
        if sys.version < '3':
            from psycopg2.extensions import register_type, UNICODE
            register_type(UNICODE)
        self.dbconn = DbConnection(dbname)
        self.film = FilmHandler(self.dbconn)

    def menu(self):
        while True:
            for cmd in ['Films', 'Quit']:
                print('  %s - %s' % (cmd[:1], cmd))
            cmd = raw_input("Command? ").upper()[:1]
            if cmd == 'Q':
                break
            elif cmd == 'F':
                if self.film.menu() == 'Q':
                    break
            else:
                print("Invalid choice")
        self.dbconn.close()
        print "Done"
Example #3
0
 def connection(self):
     return DbConnection(self.pgdb.name, self.pgdb.user, None,
                         self.pgdb.host, self.pgdb.port)
Example #4
0
 def __init__(self, dbname):
     if sys.version < '3':
         from psycopg2.extensions import register_type, UNICODE
         register_type(UNICODE)
     self.dbconn = DbConnection(dbname)
     self.film = FilmHandler(self.dbconn)