Exemplo n.º 1
0
class SQLAlchemy(Database):

    _PROTOCOL = "postgres"
    _USER = environment.get_unicode(unicode("PGUSER"))
    _PASSWORD = environment.get_unicode(unicode("PGPASSWORD"))
    _HOST = environment.get_unicode(unicode("PGHOST"))
    _PORT = environment.get_integer(unicode("PGPORT"))
    _PATH = environment.get_unicode(unicode("PGDATABASE"))

    def _init_db(self):
        # TODO: use a url utility package for this sort of thing.
        url = "{}://{}:{}@{}:{}/{}".format(self._PROTOCOL, self._USER,
                                           self._PASSWORD, self._HOST,
                                           self._PORT, self._PATH)

        # our dev instance of PostGres only allows for 20 connections across
        # all applications (Jackalope, SendJack, Prod/Staging/Warman/Hammer)
        engine = create_engine(
            url,
            #echo=True,
            #echo_pool=True,
            # As we have a lot of clients connecting to a 20 connection DB
            # simulataneously.
            pool_size=2,
            max_overflow=1,
            # As we are getting an EOF OperationalError after long breaks
            # without queries.
            pool_recycle=120)

        # create_all must be called after the objects are imported.
        DeclarativeModel.metadata.create_all(engine)

        session_factory = sessionmaker(bind=engine)
        self.session_constructor = scoped_session(session_factory)

    def session(self):
        return self.session_constructor()
Exemplo n.º 2
0
"""
import os
import tornado
import tornado.template
from tornado.options import define, options
from jinja2 import Environment, PackageLoader

from jutil import environment

# Make filepaths relative to settings.
path = lambda root, *a: os.path.join(root, *a)
ROOT = os.path.dirname(os.path.abspath(__file__))

EMBEDDABLE_DOMAIN = environment.get_unicode(unicode("EMBEDDABLE_DOMAIN"))
SSL_DOMAIN = environment.get_unicode(unicode("SSL_DOMAIN"))
PORT = environment.get_integer(unicode("PORT"), 5000)

# tornado config
define("port", default=PORT, help="run on the given port", type=int)
define("config", default=None, help="tornado config file")
define("debug", default=True, help="debug mode")
tornado.options.parse_command_line()

MEDIA_ROOT = path(ROOT, 'media')
TEMPLATE_ROOT = path(ROOT, 'view/templates')

# settings dictionary
settings = {}
settings['debug'] = options.debug
settings['static_path'] = MEDIA_ROOT
settings['cookie_secret'] = (
Exemplo n.º 3
0
"""

import os
import tornado
#import tornado.template
from tornado.options import define, options

from jutil import environment

# Make filepaths relative to settings.
path = lambda root, *a: os.path.join(root, *a)
ROOT = os.path.dirname(os.path.abspath(__file__))

# Tornado
PORT = environment.get_integer(unicode("PORT"))
define("port", default=PORT, help="run on the given port", type=int)

define("config", default=None, help="tornado config file")
define("debug", default=True, help="debug mode")
options.parse_command_line()

MEDIA_ROOT = path(ROOT, 'media')
#TEMPLATE_ROOT = path(ROOT, 'view/templates')
MAILGUN_API_KEY = environment.get_unicode(unicode("MAILGUN_API_KEY"))
MAILGUN_DOMAIN = environment.get_unicode(unicode("MAILGUN_DOMAIN"))

#
# settings dictionary
settings = {}
settings['debug'] = options.debug
Exemplo n.º 4
0
 def PORT(self):
     return environment.get_integer(unicode("PGPORT"))
Exemplo n.º 5
0
 def DEV_PROJECT_ID(self):
     return environment.get_integer(unicode("ASANA_DEV_PROJECT_ID"))
Exemplo n.º 6
0
 def WORKSPACE_ID(self):
     return environment.get_integer(unicode("ASANA_WORKSPACE_ID"))
Exemplo n.º 7
0
 def JACK_USER_ID(self):
     return environment.get_integer(unicode("ASANA_USER_ID"))