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') ])
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"
def connection(self): return DbConnection(self.pgdb.name, self.pgdb.user, None, self.pgdb.host, self.pgdb.port)
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)