Ejemplo n.º 1
0
 def __init__(self):
     # Instance of MySQL db cursor.
     self.mysql_db = sqlsoup.SQLSoup(MYSQL_URL)
     # Initializing of psql session.
     self.session = get_db_session(api.settings)()
     # Need for remembering the valid problems.
     self.problems_id = []
Ejemplo n.º 2
0
def init_db():
    """
    Creates tables by SQLAlchemy models
    """
    settings = get_normalized_settings()
    engine = get_db_engine(settings)
    Base.metadata.create_all(bind=engine)

    db = get_db_session(settings)
    factory = ServerInstancesFactory(db)
    factory.gen_servers()
Ejemplo n.º 3
0
from tornado.web import Application
from tornado.log import enable_pretty_logging
from tornado.ioloop import IOLoop

from api.utils.db import get_db_session
from api.utils.settings import get_normalized_settings
from api.v1_0.handlers.urls import APIUrls


if __name__ == "__main__":

    settings = get_normalized_settings()
    # APIUrls is in v1_0/handlers/urls.py -- path table
    application = Application(handlers=APIUrls, **settings)
    # attaching database here -- used to initialize request handlers
    # see base.py db property
    application.db = get_db_session(settings)

    if settings['debug']:
        enable_pretty_logging()
        # simple single process pattern
        application.listen(settings['bind_port'], settings['bind_addr'], )
    else:
        server = HTTPServer(application)
        # simple multi-process pattern
        server.bind(settings['bind_port'], settings['bind_addr'] )
        server.start(settings['tornado_start'])

    print 'starting server...'
    IOLoop.instance().start()
Ejemplo n.º 4
0
 def setUp(self):
     super(CommentsAsyncHTTPTestCase, self).setUp()
     self.data = json.dumps(
         dict(content='avaba kedabra', user_id=1, modified_user_id=2))
     self.headers = {'Content-Type': 'application/json; charset=UTF-8'}
     self.session = get_db_session(settings)()
Ejemplo n.º 5
0
 def __init__(self, handlers, **settings):
     Application.__init__(self, handlers, **settings)
     self.db = get_db_session(settings)
     self.thread_pool = ThreadPoolExecutor(1)
Ejemplo n.º 6
0
from sqlalchemy import orm
from api.utils.db import get_db_session
from api import settings

Session = orm.scoped_session(get_db_session(settings))
Ejemplo n.º 7
0
import wtforms_json
from wtforms_alchemy import ModelForm
from api.v1_0.models import Page
from api.utils.db import get_db_session
from api import settings

session = get_db_session(settings)
wtforms_json.init


class PageForm(ModelForm):
    class Meta:
        model = Page

    @classmethod
    def get_session(self):
        return session()


class PageUpdateFrom(ModelForm):
    class Meta:
        model = Page
        unique_validator = None