Exemplo n.º 1
0
def main(global_config, **settings):
    engine = engine_from_config(settings, 'sqlalchemy.')
    DBSession.configure(bind=engine)
    metadata.bind = engine

    config = Configurator(settings=settings)

    if asbool(settings['debug']):
        config.add_static_view('static', path='static/', cache_max_age=1)
        config.add_static_view('css', path='static/css/', cache_max_age=1)
        config.add_static_view('img', path='static/img/', cache_max_age=1)
        config.add_static_view('js', path='static/js/', cache_max_age=1)
        config.add_static_view('templates', path='templates/', cache_max_age=1)

    # User
    config.add_route('users', '/users*args')
    config.add_view('confrm.handlers.users.UserHandler', route_name='users')
    config.add_route('user_sessions', '/user_sessions*args')
    config.add_view('confrm.handlers.user_sessions.UserSessionHandler', route_name='user_sessions')
    config.add_route('files', '/files*args')
    config.add_view('confrm.handlers.files.FileHandler', route_name='files')
    config.add_route('groups', '/groups*args')
    config.add_view('confrm.handlers.groups.GroupHandler', route_name='groups')

    config.add_notfound_view('confrm.handlers.error404')
    config.add_route('root', '/')

    return config.make_wsgi_app()
Exemplo n.º 2
0
argd = dict()
for arg1, arg2 in zip(sys.argv, sys.argv[1:]):
    if arg1.startswith('--'):
        key = arg1.replace('--', '')
        if arg2.startswith('--'):
            argd[key] = True
        else:
            argd[key] = arg2

config = ConfigParser(dict(here=os.getcwd()))
config.read([arg for arg in sys.argv if arg.endswith('.ini')][0])
app_config = dict(config.items('app:main'))

engine = engine_from_config(app_config)
DBSession.configure(bind=engine)
metadata.bind = engine

from confrm.models import Organization, User, OrganizationUser

user = None
org = None
if 'user-email' in argd:
    user = User(email=argd['user-email'], root=True)
    user.set_password(argd['user-password'])
    DBSession.add(user)
    DBSession.flush()
    print 'Added email'

if 'org-slug' in argd:
    org = Organization(slug=argd['org-slug'], name=argd['org-name'])