Beispiel #1
0
def init():
    from deform import Form
    from deform_jinja2 import jinja2_renderer_factory
    from deform_jinja2.translator import PyramidTranslator

    renderer = jinja2_renderer_factory(search_paths=SEARCH_PATHS,
                                       translator=PyramidTranslator())

    Form.set_default_renderer(renderer)
Beispiel #2
0
def init():
    from deform import Form
    from deform_jinja2 import jinja2_renderer_factory
    from deform_jinja2.translator import PyramidTranslator

    renderer = jinja2_renderer_factory(search_paths=SEARCH_PATHS,
                                       translator=PyramidTranslator())

    Form.set_default_renderer(renderer)
Beispiel #3
0
from deform_jinja2.translator import PyramidTranslator
from deform_jinja2 import jinja2_renderer_factory

jinja2_renderer = jinja2_renderer_factory(search_paths=('tvshowshack:templates/',), translator=PyramidTranslator())
Beispiel #4
0
from deform_jinja2.translator import PyramidTranslator
from deform_jinja2 import jinja2_renderer_factory

jinja2_renderer = jinja2_renderer_factory(search_paths=('deformdemo:templates/',), translator=PyramidTranslator())
Beispiel #5
0
def main(global_config, **settings):
    """ This function returns a Pyramid WSGI application.
    """
    engine = engine_from_config(settings, 'sqlalchemy.')
    DBSession.configure(bind=engine)
    session_factory = session_factory_from_settings(settings)
    authn_policy = AuthTktAuthenticationPolicy('pyvor3', callback=groupfinder)

    authz_policy = ACLAuthorizationPolicy()

    config = Configurator(settings=settings,
                          session_factory=session_factory,
                          authorization_policy=authz_policy,
                          authentication_policy=authn_policy)

    config.add_subscriber(handle_request, PasswordResetEvent)
    config.add_subscriber(handle_request, NewRegistrationEvent)
    config.add_subscriber(handle_request, RegistrationActivatedEvent)
    config.add_subscriber(handle_request, ProfileUpdatedEvent)

    config.registry.registerUtility(DBSession, ISession)

    jst = Bundle('templates/*.html',
                 filters='jst',
                 output='jst.js',
                 debug=False)

    config.add_webasset('jst', jst)

    # jinja2 configuration
    config.add_jinja2_extension('jinja2.ext.i18n')
    config.add_jinja2_extension('webassets.ext.jinja2.AssetsExtension')
    config.add_jinja2_search_path(os.path.join(here, 'templates'))
    config.add_jinja2_search_path("pyvore:templates")

    jinja2_env = config.get_jinja2_environment()

    assets_env = config.get_webassets_env()
    jinja2_env.assets_environment = assets_env

    renderer = jinja2_renderer_factory(
        search_paths=('pyvore:templates/', ),
        default_templates='deform_jinja2:bootstrap_templates',
        translator=PyramidTranslator())

    deform.Form.set_default_renderer(renderer)

    # The are from pyramid_signup, we are overriding them to use CouchForm
    # for rendering
    override_forms = [
        ISULoginForm, ISURegisterForm, ISUForgotPasswordForm,
        ISUResetPasswordForm, ISUProfileForm
    ]

    for form in override_forms:
        config.registry.registerUtility(PyvoreForm, form)

    config.registry.registerUtility(DBSession, ISUSession)

    config.include('pyvore.routes')

    config.scan()

    return config.make_wsgi_app()
Beispiel #6
0
    def test_add_filter(self):
        rf = deform_jinja2.jinja2_renderer_factory()  # coverage
        rf.add_filter('awesome_filter', lambda value: value[1:])

        assert 'awesome_filter' in rf.env.filters
Beispiel #7
0
 def test_default_translator_is_dummy(self):
     rf = deform_jinja2.jinja2_renderer_factory()  # coverage
     assert rf.env.globals['gettext'] == deform_jinja2.DummyTranslator(
     ).gettext
     assert rf.env.globals['ngettext'] == deform_jinja2.DummyTranslator(
     ).ngettext
Beispiel #8
0
    def shutdown_session(exception=None):
        if exception is None:
            Session.commit()
        Session.remove()

    return flask_app


# def log_request_info():
#     current_app.logger.debug(u'Headers: %s', request.headers)
#     current_app.logger.debug(u'Body: %s', request.get_data())
#     print 'logging..'

if __name__ == '__main__':
    # bootstrap_widget_templates_path = os.path.join(get_root_path(), 'templates', 'bootstrap_widget_templates')
    renderer = jinja2_renderer_factory(
        search_paths=['fakturahr:templates/bootstrap_widget_templates'])
    Form.set_default_renderer(renderer)
    init_models()

    init_db()

    app = create_app()

    log_handler = TimedRotatingFileHandler(filename=os.path.join(
        get_root_path(), config.LOG_FILE_PATH),
                                           when='midnight',
                                           backupCount=365)
    formatter = logging.Formatter(
        u'[%(asctime)s] {%(levelname)s - %(message)s')
    log_handler.setFormatter(formatter)
    app.logger.addHandler(log_handler)
Beispiel #9
0
def main(global_config, **settings):
    """ This function returns a Pyramid WSGI application.
    """
    engine = engine_from_config(settings, 'sqlalchemy.')
    DBSession.configure(bind=engine)
    session_factory = session_factory_from_settings(settings)
    authn_policy = AuthTktAuthenticationPolicy('pyvor3',
                 callback=groupfinder)

    authz_policy = ACLAuthorizationPolicy()

    config = Configurator(
        settings=settings,
        session_factory=session_factory,
        authorization_policy=authz_policy,
        authentication_policy=authn_policy
    )

    config.add_subscriber(handle_request, PasswordResetEvent)
    config.add_subscriber(handle_request, NewRegistrationEvent)
    config.add_subscriber(handle_request, RegistrationActivatedEvent)
    config.add_subscriber(handle_request, ProfileUpdatedEvent)

    config.registry.registerUtility(DBSession, ISession)

    jst = Bundle('templates/*.html',
            filters='jst',
            output='jst.js', debug=False)

    config.add_webasset('jst', jst)


    # jinja2 configuration
    config.add_jinja2_extension('jinja2.ext.i18n')
    config.add_jinja2_extension('webassets.ext.jinja2.AssetsExtension')
    config.add_jinja2_search_path(os.path.join(here, 'templates'))
    config.add_jinja2_search_path("pyvore:templates")

    jinja2_env = config.get_jinja2_environment()

    assets_env = config.get_webassets_env()
    jinja2_env.assets_environment = assets_env

    renderer = jinja2_renderer_factory(
        search_paths=(
            'pyvore:templates/',
        ),
        default_templates='deform_jinja2:bootstrap_templates',
        translator=PyramidTranslator()
    )

    deform.Form.set_default_renderer(renderer)

    # The are from pyramid_signup, we are overriding them to use CouchForm
    # for rendering
    override_forms = [
        ISULoginForm, ISURegisterForm, ISUForgotPasswordForm,
        ISUResetPasswordForm, ISUProfileForm
    ]

    for form in override_forms:
        config.registry.registerUtility(PyvoreForm, form)

    config.registry.registerUtility(DBSession, ISUSession)

    config.include('pyvore.routes')

    config.scan()

    return config.make_wsgi_app()
Beispiel #10
0
 def test_default_translator_is_dummy(self):
     rf = deform_jinja2.jinja2_renderer_factory() # coverage
     assert rf.env.globals['gettext'] == deform_jinja2.DummyTranslator().gettext
     assert rf.env.globals['ngettext'] == deform_jinja2.DummyTranslator().ngettext
     
Beispiel #11
0
def main(global_config, **settings):
    """ This function returns a Pyramid WSGI application.
    """

    if os.environ.get('OPENSHIFT_APP_NAME', None):
        url = u"postgresql+psycopg2://%(username)s:%(password)s@%(host)s:%(port)s/%(database)s" % {
            'username': os.environ['OPENSHIFT_DB_USERNAME'],
            'password': os.environ['OPENSHIFT_DB_PASSWORD'],
            'host': os.environ['OPENSHIFT_DB_HOST'],
            'port': os.environ['OPENSHIFT_DB_PORT'],
            'database': os.environ['OPENSHIFT_APP_NAME']
        }

        engine = create_engine(url)
    else:
        engine = engine_from_config(settings, 'sqlalchemy.')

    DBSession.configure(bind=engine)
    Base.metadata.bind = engine
    Base.metadata.create_all(engine)


    authn_policy = AuthTktAuthenticationPolicy('pc0lalugs0secret', callback=groupfinder)

    authz_policy = ACLAuthorizationPolicy()

    session_factory = session_factory_from_settings(settings)

    data_dir = get_data_dir()
    settings['upload_dir'] = os.path.join(data_dir, 'uploads')

    config = Configurator(settings=settings)

    config = Configurator(
        settings=settings,
        authentication_policy=authn_policy,
        authorization_policy=authz_policy,
        session_factory=session_factory
    )

    renderer = jinja2_renderer_factory(default_templates='deform_jinja2:uni_templates', translator=PyramidTranslator()
    )

    deform.Form.set_default_renderer(renderer)

    config.registry.registerUtility(DBSession, IDBSession)

    config.include('pyramid_mailer')

    config.include('horus')

    config.add_view('horus.views.AuthController', attr='login', route_name='horus_login',
            renderer='pcolalug:templates/login.jinja2')

    config.add_view('horus.views.ForgotPasswordController', attr='forgot_password', route_name='horus_forgot_password',
            renderer='pcolalug:templates/forgot_password.jinja2')

    config.add_view('horus.views.ForgotPasswordController', attr='reset_password', route_name='horus_reset_password',
            renderer='pcolalug:templates/reset_password.jinja2')

    config.add_view('horus.views.RegisterController', attr='register', route_name='horus_register',
            renderer='pcolalug:templates/register.jinja2')

    config.add_view('horus.views.ProfileController', attr='profile', route_name='horus_profile',
            renderer='pcolalug:templates/profile.jinja2',
            permission='access_user')

    override_forms = [
        IHorusLoginForm, IHorusRegisterForm, IHorusForgotPasswordForm,
        IHorusResetPasswordForm, IHorusProfileForm
    ]
    for form in override_forms:
        config.registry.registerUtility(UNIForm, form)

    config.registry.registerUtility(LUGProfileSchema, IHorusProfileSchema)


    config.add_static_view('static', 'pcolalug:static', cache_max_age=3600)
    config.add_static_view('data', get_data_dir(), cache_max_age=3600)
    config.add_route('index', '/') 
    config.add_route('contact', '/contact')
    config.add_route('calendar', '/calendar')
    config.add_route('admin', '/admin')
    config.add_route('presentations', '/presentations')
    config.add_route('view_presentation', '/presentations/{pk}')
    config.add_route('add_presentation', '/add/presentation')
#    config.add_route('admin_profile', '/profile/{id}')

    config.add_subscriber(handle_profile_group, ProfileUpdatedEvent)

    config.scan()

    return config.make_wsgi_app()
Beispiel #12
0
    def test_add_filter(self):
        rf = deform_jinja2.jinja2_renderer_factory() # coverage
        rf.add_filter('awesome_filter', lambda value: value[1:])

        assert 'awesome_filter' in rf.env.filters