Fix logging and connections on PAAS.

This commit is contained in:
James Socol 2013-04-26 11:52:51 -04:00
Родитель f441e96575
Коммит d07bd819bd
2 изменённых файлов: 17 добавлений и 2 удалений

Просмотреть файл

@ -1,4 +1,5 @@
from __future__ import absolute_import
import logging
from flask import Flask
@ -6,4 +7,9 @@ from flask import Flask
app = Flask(__name__)
log_handler = logging.StreamHandler()
log_handler.setLevel(logging.WARNING)
app.logger.addHandler(log_handler)
import matchpoint.views

Просмотреть файл

@ -1,3 +1,4 @@
import json
import os
from mongoalchemy import fields
@ -12,18 +13,26 @@ class DocumentBase(Document):
def __unicode__(self):
return u'<%s>' % self.__class__.__name__
# def get_host(self):
# services = json.loads(os.getenv(
def to_dict(self):
raise NotImplemented()
def save(self):
host = os.getenv('MONGODB_URL', 'localhost')
s = Session.connect('default', host) # XXX
s = Session.connect('db', host=host) # XXX
return s.insert(self)
def delete(self):
host = os.getenv('MONGODB_URL', 'localhost')
s = Session.connect('db', host=host)
return s.remove(self)
@classmethod
def query(cls):
host = os.getenv('MONGODB_URL', 'localhost')
s = Session.connect('default', host) # XXX
s = Session.connect('db', host=host) # XXX
return s.query(cls)