Example #1
0
def _init_postgresql():
    database = config.get('database', 'database')
    kwargs = dict(
        host        = config.get('database', 'hostname'),
        user        = config.get('database', 'username'),
        password    = config.get('database', 'password')        
    )
    _db.init(database, **kwargs)
Example #2
0
def _init_postgresql():
    database = config.get('database', 'database')
    kwargs = dict(
        host        = config.get('database', 'hostname'),
        user        = config.get('database', 'username'),
        password    = config.get('database', 'password')        
    )
    _db.init(database, **kwargs)
Example #3
0
Copyright (c) 2013—2014 Andrea Peltrin
Portions are copyright (c) 2013 Rui Carmo
License: MIT (see LICENSE.md for details)
'''
import sys, os, re
from traceback import format_tb

from webob import Request, Response
from webob.exc import *

from utilities import *
from models import connect
from coldsweat import log, config, installation_dir

# Figure out static dir, if given
STATIC_URL = config.get('web', 'static_url') if config.has_option('web', 'static_url') else ''


# ------------------------------------------------------
# Decorators
# ------------------------------------------------------

def on(pattern, http_methods):    
    def wrapper(handler):         
        handler.pattern = re.compile(pattern, re.U)
        handler.http_methods = [m.upper() for m in http_methods]
        return handler         
    return wrapper  

def GET(pattern='^/$'):    
    return on(pattern, ('get', ))  
Example #4
0
def _init_sqlite():
    filename = config.get('database', 'filename')
    _db.init(filename)    
Example #5
0
Portions are copyright (c) 2013 Rui Carmo
License: MIT (see LICENSE.md for details)
"""

import pickle
from datetime import datetime, timedelta
from peewee import *
from playhouse import migrate
from webob.exc import status_map

from utilities import *
import favicon
from coldsweat import config, log

# Defer database init, see connect() below
engine = config.get('database', 'engine')
if engine == 'sqlite':
    _db = SqliteDatabase(None, threadlocals=True) 
elif engine == 'mysql':
    _db = MySQLDatabase(None)
elif engine == 'postgresql':
    _db = PostgresqlDatabase(None, autorollback=True)
else:
    raise ValueError('Unknown database engine %s. Should be sqlite, postgresql or mysql' % engine)

# ------------------------------------------------------
# Custom fields
# ------------------------------------------------------

class PickleField(BlobField):
    def db_value(self, value):
Example #6
0
def _init_sqlite():
    filename = config.get('database', 'filename')
    _db.init(filename)    
Example #7
0
Portions are copyright (c) 2013 Rui Carmo
License: MIT (see LICENSE.md for details)
"""

import pickle
from datetime import datetime, timedelta
from peewee import *
from playhouse import migrate
from webob.exc import status_map

from utilities import *
import favicon
from coldsweat import config, log

# Defer database init, see connect() below
engine = config.get('database', 'engine')
if engine == 'sqlite':
    from sqlite3 import IntegrityError, ProgrammingError
    _db = SqliteDatabase(None, threadlocals=True) 
elif engine == 'mysql':
    from MySQLdb import IntegrityError, ProgrammingError
    _db = MySQLDatabase(None)
elif engine == 'postgresql':
    from psycopg2 import IntegrityError, ProgrammingError
    _db = PostgresqlDatabase(None)
else:
    raise ValueError('Unknown database engine %s. Should be sqlite, postgresql or mysql' % engine)

# ------------------------------------------------------
# Custom fields
# ------------------------------------------------------