From b74fb8c4c86f8b194ff2f6d2004b1b299a4b3d91 Mon Sep 17 00:00:00 2001 From: Joshua McKenty Date: Wed, 17 Apr 2013 13:40:42 -0700 Subject: [PATCH] Fixin spaces --- fabfile.py | 2 +- refstack/web.py | 42 ++++++++++-------------------------------- 2 files changed, 11 insertions(+), 33 deletions(-) diff --git a/fabfile.py b/fabfile.py index b70c81d0..3a42970d 100644 --- a/fabfile.py +++ b/fabfile.py @@ -19,5 +19,5 @@ def deploy(): run('git checkout master') run('git pull') run('sudo pip install -r requirements.txt') - run('sudo python -c "from refstack import web; web.init_db()"') + run('sudo python -c "from refstack import web; web.db.create_all()"') run('sudo uwsgi --reload /tmp/project-master_refstack.pid') \ No newline at end of file diff --git a/refstack/web.py b/refstack/web.py index 637903be..472cef70 100644 --- a/refstack/web.py +++ b/refstack/web.py @@ -17,42 +17,20 @@ app.debug = True app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:////var/www/refstack/database.db' db = SQLAlchemy(app) - class Vendor(db.Model): - id = db.Column(db.Integer, primary_key=True) - vendor_name = db.Column(db.String(80), unique=True) - contact_email = db.Column(db.String(120), unique=True) + id = db.Column(db.Integer, primary_key=True) + vendor_name = db.Column(db.String(80), unique=True) + contact_email = db.Column(db.String(120), unique=True) - def __init__(self, username, email): - self.vendor_name = vendor_name - self.contact_email = contact_email + def __init__(self, username, email): + self.vendor_name = vendor_name + self.contact_email = contact_email + + def __repr__(self): + return '' % self.vendor_name - def __repr__(self): - return '' % self.vendor_name - -# -# @app.before_request -# def before_request(): -# g.db = connect_db() -# -# @app.teardown_request -# def teardown_request(exception): -# if hasattr(g, 'db'): -# g.db.close() -# -# def query_db(query, args=(), one=False): -# cur = g.db.execute(query, args) -# rv = [dict((cur.description[idx][0], value) -# for idx, value in enumerate(row)) for row in cur.fetchall()] -# return (rv[0] if rv else None) if one else rv -# -# def init_db(): -# with closing(connect_db()) as db: -# with app.open_resource('schema.sql') as f: -# db.cursor().executescript(f.read()) -# db.commit() @app.route('/', methods=['POST','GET']) def index(): - vendors = Vendor.query.all() + vendors = Vendor.query.all() return render_template('index.html', vendors = vendors) \ No newline at end of file