예제 #1
0
def main(global_config, **settings):
    """ This function returns a Pyramid WSGI application.
    """
    engine = engine_from_config(settings, 'sqlalchemy.')
    initialize_sql(engine)
    session_factory = UnencryptedCookieSessionFactoryConfig('itsaseekreet')
    config = Configurator(settings=settings, session_factory=session_factory)
    config.add_static_view('static', 'myproject:static', cache_max_age=3600)
    config.add_route('list', '/')
    config.add_route('new', '/new')
    config.add_route('close', '/close/{id}')
    config.add_view('myproject.views.list_view',
                    route_name='list',
                    renderer='list.mako')
    config.add_view('myproject.views.new_view',
                    route_name='new',
                    renderer='new.mako')
    config.add_view('myproject.views.close_view',
                    route_name='close',
                    renderer='list.mako')
    return config.make_wsgi_app()
예제 #2
0
파일: tests.py 프로젝트: cgopalan/ToDoList
def _initTestingDB():
    from sqlalchemy import create_engine
    from myproject.models import initialize_sql
    session = initialize_sql(create_engine('sqlite://'))
    return session
예제 #3
0
def main(global_config, **settings):
    """ This function returns a Pyramid WSGI application.
    """
    engine = engine_from_config(settings, 'sqlalchemy.')
    initialize_sql(engine)

    session_factory = session_factory_from_settings(settings)

    #authn_policy = AuthTktAuthenticationPolicy(
    #                                            '21(*^=s2ws%^~1`~|2JHFG1267fYTsaa1kjgh325URHfa', 
    #                                            callback=groupfinder,
    #                                            cookie_name='authcookie',
    #                                            secure=True,
    #                                            timeout=3600,
    #                                            reissue_time=360,
    #                                           )
    authn_policy = SessionAuthenticationPolicy(
                                                callback=groupfinder,
                                                #debug=True,
                                              )
    authz_policy = ACLAuthorizationPolicy()

    config = Configurator(
        settings=settings,
        root_factory=RootFactory,
        authentication_policy=authn_policy,
        authorization_policy=authz_policy,
        introspection=False
        )

    config.registry['mailer'] = mailer_factory_from_settings(settings)
    config.set_session_factory(session_factory)

    config.set_locale_negotiator(locale_negotiator)

    #this add a ".user" property to the request object and run
    #"get_user" internal functions only when assigned to a variable 
    #to get the user data: "user = request.user"
    config.set_request_property(get_user, 'user', reify=True)

    config.add_subscriber('myproject.subscribers.add_renderer_globals',
                          'pyramid.events.BeforeRender')
    #config.add_subscriber('myproject.subscribers.add_localizer',
    #                      'pyramid.events.NewRequest')
    #config.add_subscriber('myproject.subscribers.csrf_validation_event',
    #                      'pyramid.events.NewRequest')
    config.add_subscriber('myproject.subscribers.new_request',
                          'pyramid.events.NewRequest')

    config.add_translation_dirs('myproject:locale')

    #config.add_static_view('captcha_imgs', 'myproject:captcha_imgs')
    #config.add_static_view('static-deform', 'deform:static')
    #config.add_static_view('static', 'myproject:static')
    config.add_static_view(name='http://cdn.mumberla.com/static', path='myproject:static')
    #config.add_static_view('static', 'myproject:static', cache_max_age=3600)

    #config.include('deform_bootstrap')

    config.add_route('home', '/')
    config.add_route('login', '/login')
    config.add_route('signup', '/signup')
    config.add_route('captcha-img', '/captcha-img/{captcha_image}')
    config.add_route('logout', '/logout')

    config.add_route('users', '/users', factory=UserFactory)
    config.add_route('user', '/user/{login}', factory=UserFactory, traverse='/{login}')
    config.add_route('support-key', '/support-key/{username}/{key}')
    config.add_route('support-pwd', '/support-pwd/{username}/{key}')
    config.add_route('change-locale', '/support-loc/{locale}')
   
    config.add_route('dids', '/dids', factory=UserFactory)
    
    config.add_route('twitter_login', '/twitter/login')
    config.add_route('twitter_process', '/twitter/process')
    
    config.add_route('agile_sms', '/agile/post')
    config.add_route('speak', '/speak')
    config.add_route('call', '/call')
    config.add_route('chat', '/chat')

    config.add_route('pages', '/pages', factory=PageFactory)
    config.add_route('create_page', '/create_page', factory=PageFactory)
    config.add_route('page', '/page/{title}', factory=PageFactory, traverse='/{title}')
    #config.add_route('page', '/page/{title}', factory=PageFactory)
    config.add_route('edit_page', '/page/{title}/edit', factory=PageFactory, traverse='/{title}')
    #config.add_route('edit_page', '/page/{title}/edit', factory=PageFactory)
    
    #config.add_static_view('static', 'myproject:static', cache_max_age=3600)

    #config.add_route('main_view', '/')
    #config.add_view('myproject.views.main_view', route_name='main_view')
    
    #config.add_route('login', '/login')
    #config.add_view('myproject.views.login', 
    #                context='pyramid.httpexceptions.HTTPForbidden',
    #                renderer='myproject:templates/login.pt') 
    #config.add_view('myproject.views.login', route_name='login',
    #                renderer='myproject:templates/login.pt') 
    
    #config.add_route('user', '/{login}' factory=UserFactory)
    #config.add_route('user', '/user/{login}', factory=UserFactory, traverse='/{login}')
    #config.add_view('myproject.views.view_page', route_name='view_page', 
    #                permission='edit',
    #                renderer='myproject:templates/view.pt')
    
    #config.add_route('register', '/register')
    #config.add_view('myproject.views.user_add', route_name='register',
    #                permission='view',
    #                renderer='templates/user_add.pt')

    #config.add_route('add_page', '/add_page/{pagename}')
    #config.add_view('myproject.views.add_page', route_name='add_page',
    #                 renderer='myproject:templates/edit.pt', permission='edit')
    
    #config.add_route('edit_page', '/{pagename}/edit_page')
    #config.add_view('myproject.views.edit_page', route_name='edit_page',
    #                 renderer='myproject:templates/edit.pt', permission='edit')

    #config.add_route('logout', '/logout')
    #config.add_view('myproject.views.logout', route_name='logout')

    #config.add_route('home', '/home')
    #config.add_view('myproject.views.my_view',
    #                route_name='home',
    #                renderer='templates/mytemplate.pt')



    config.scan()

    return config.make_wsgi_app()