Files
Chad Whitacre 28cb48c72a Big changeover from id to username; #287
I sort of did this one with the blast shield down. I haven't even run
the tests yet. The sorts of things I changed:

 - SQL {elsewhere,exchanges}.participant_id => .participant
 - SQL participants.id => .username
 - ORM {user,participant,self}.id => .username
2013-04-05 15:48:59 -04:00

66 lines
1.9 KiB
Python

"""Wireup
"""
import os
import sys
import aspen
import balanced
import gittip
import raven
import psycopg2
import stripe
from gittip.postgres import PostgresManager
from psycopg2.extensions import cursor as RegularCursor
def canonical():
gittip.canonical_scheme = os.environ['CANONICAL_SCHEME']
gittip.canonical_host = os.environ['CANONICAL_HOST']
# wireup.db() should only ever be called once by the application
def db():
dburl = os.environ['DATABASE_URL']
maxconn = int(os.environ['DATABASE_MAXCONN'])
gittip.db = PostgresManager(dburl, maxconn=maxconn)
# register hstore type (but don't use RealDictCursor)
with gittip.db.get_connection() as conn:
curs = conn.cursor(cursor_factory=RegularCursor)
psycopg2.extras.register_hstore(curs, globally=True, unicode=True)
return gittip.db
def billing():
stripe.api_key= os.environ['STRIPE_SECRET_API_KEY']
stripe.publishable_api_key= os.environ['STRIPE_PUBLISHABLE_API_KEY']
balanced.configure(os.environ['BALANCED_API_SECRET'])
def username_restrictions(website):
gittip.RESTRICTED_USERNAMES = os.listdir(website.www_root)
def sentry(website):
sentry_dsn = os.environ.get('SENTRY_DSN')
if sentry_dsn is not None:
sentry = raven.Client(sentry_dsn)
def tell_sentry(request):
cls, response = sys.exc_info()[:2]
if cls is aspen.Response:
if response.code < 500:
return
kw = {'extra': { "filepath": request.fs
, "request": str(request).splitlines()
}}
exc = sentry.captureException(**kw)
ident = sentry.get_ident(exc)
aspen.log_dammit("Exception reference: " + ident)
website.hooks.error_early += [tell_sentry]
def mixpanel(website):
website.mixpanel_token = os.environ['MIXPANEL_TOKEN']