Esempio n. 1
0
def includeme(config):
    settings = config.registry.settings

    if not config.registry.queryUtility(IHieroEntryClass):
        entry_class = get_class_from_config(settings, 'hiero.entry_class')
        config.registry.registerUtility(entry_class, IHieroEntryClass)

    if not config.registry.queryUtility(IHieroSeriesClass):
        series_class = get_class_from_config(settings, 'hiero.series_class')
        config.registry.registerUtility(series_class, IHieroSeriesClass)

    if not config.registry.queryUtility(IHieroCategoryClass):
        cat_class = get_class_from_config(settings, 'hiero.category_class')
        config.registry.registerUtility(cat_class, IHieroCategoryClass)

    if not config.registry.queryUtility(IHieroTagClass):
        cat_class = get_class_from_config(settings, 'hiero.tag_class')
        config.registry.registerUtility(cat_class, IHieroTagClass)

    if not config.registry.queryUtility(IHieroEntryTagClass):
        cat_class = get_class_from_config(settings, 'hiero.entry_tag_class')
        config.registry.registerUtility(cat_class, IHieroEntryTagClass)


    config.include('hiero.routes')

 #   config.add_route('get_pages',   '/pages') 
 #   config.add_route('get_page',    '/pages/{link_title}')
 #   config.add_route('edit_page',   '/pages/{link_title}/edit')
 #   config.add_route('add_page',    '/add_page')
 #   config.add_route('remove_page', '/pages/{link_title}/remove')
    config.add_subscriber(add_renderer_globals, 'pyramid.events.BeforeRender')
    config.scan()
    return config.make_wsgi_app()
Esempio n. 2
0
def includeme(config):
    settings = config.registry.settings
    config.set_request_property(get_user_account, 'user_account', reify=True)

    config.set_root_factory(RootFactory)


    if not config.registry.queryUtility(IHorusUserClass):
        user_class = get_class_from_config(settings, 'horus.user_class')
        config.registry.registerUtility(user_class, IHorusUserClass)

    if not config.registry.queryUtility(IHorusUserAccountClass):
        user_account_class = get_class_from_config(settings, 'horus.user_account_class')
        config.registry.registerUtility(user_account_class, IHorusUserAccountClass)

    if not config.registry.queryUtility(IHorusGroupClass):
        group_class = get_class_from_config(settings, 'horus.group_class')
        config.registry.registerUtility(group_class, IHorusGroupClass)

    if not config.registry.queryUtility(IHorusActivationClass):
        activation_class = get_class_from_config(settings,
                'horus.activation_class')
        config.registry.registerUtility(activation_class,
                IHorusActivationClass)

    if not config.registry.queryUtility(IHorusVelruseStore):
        # setup velruse token storage
        storage_string = settings.get('horus.velruse.store', 'memory')
        settings['horus.velruse.store.store'] = storage_string
        velruse_store = create_store_from_settings(settings, prefix='horus.velruse.store.')
        config.registry.registerUtility(velruse_store,
            IHorusVelruseStore)

    schemas = [
        (IHorusLoginSchema, LoginSchema),
        (IHorusRegisterSchema, RegisterSchema),
        (IHorusRegisterEmailSchema, RegisterEmailSchema),
        (IHorusForgotPasswordSchema, ForgotPasswordSchema),
        (IHorusResetPasswordSchema, ResetPasswordSchema),
        (IHorusProfileSchema, ProfileSchema)
    ]

    forms = [
        IHorusLoginForm, IHorusRegisterForm, IHorusRegisterEmailForm, IHorusForgotPasswordForm,
        IHorusResetPasswordForm, IHorusProfileForm
    ]

    for iface, schema in schemas:
        if not config.registry.queryUtility(iface):
            config.registry.registerUtility(schema, iface)

    for form in forms:
        if not config.registry.queryUtility(form):
            config.registry.registerUtility(SubmitForm, form)

    config.include('horus.routes')
    config.scan(ignore=['.test', '.testing', '.tests'])

    config.add_translation_dirs('horus:locale/')
Esempio n. 3
0
def includeme(config):
    settings = config.registry.settings
    # str('user') returns a bytestring under Python 2 and a
    # unicode string under Python 3, which is what we need:
    config.add_request_method(get_user, str('user'), reify=True)
    config.set_root_factory(RootFactory)

    config.add_directive('scan_horus', scan)

    if not config.registry.queryUtility(IUserClass):
        try:
            user_class = get_class_from_config(settings, 'horus.user_class')
            config.registry.registerUtility(user_class, IUserClass)
        except:
            # maybe they are using scan?
            pass

    if not config.registry.queryUtility(IActivationClass):
        try:
            activation_class = get_class_from_config(settings,
                    'horus.activation_class')
            config.registry.registerUtility(activation_class,
                    IActivationClass)
        except:
            # maybe they are using scan?
            pass

    defaults = [
        (IUIStrings, UIStringsBase),
        (ILoginSchema, LoginSchema),
        (IRegisterSchema, RegisterSchema),
        (IForgotPasswordSchema, ForgotPasswordSchema),
        (IResetPasswordSchema, ResetPasswordSchema),
        (IProfileSchema, ProfileSchema)
    ]

    forms = [
        ILoginForm, IRegisterForm, IForgotPasswordForm,
        IResetPasswordForm, IProfileForm
    ]

    for iface, default in defaults:
        if not config.registry.queryUtility(iface):
            config.registry.registerUtility(default, iface)

    for form in forms:
        if not config.registry.queryUtility(form):
            config.registry.registerUtility(SubmitForm, form)


    def on_before_render(event):
        fn = render_flash_messages_from_queues
        event['render_flash_messages'] = lambda: fn(event['request'])

    config.add_subscriber(on_before_render, BeforeRender)

    config.include('horus.routes')
    config.scan(ignore=str('horus.tests'))
Esempio n. 4
0
def includeme(config):
    settings = config.registry.settings
    # str('user') returns a bytestring under Python 2 and a
    # unicode string under Python 3, which is what we need:
    config.add_request_method(get_user, str('user'), reify=True)
    config.set_root_factory(RootFactory)

    config.add_directive('scan_horus', scan)

    if not config.registry.queryUtility(IUserClass):
        try:
            user_class = get_class_from_config(settings, 'horus.user_class')
            config.registry.registerUtility(user_class, IUserClass)
        except:
            # maybe they are using scan?
            pass

    if not config.registry.queryUtility(IActivationClass):
        try:
            activation_class = get_class_from_config(settings,
                                                     'horus.activation_class')
            config.registry.registerUtility(activation_class, IActivationClass)
        except:
            # maybe they are using scan?
            pass

    defaults = [(IUIStrings, UIStringsBase), (ILoginSchema, LoginSchema),
                (IRegisterSchema, RegisterSchema),
                (IForgotPasswordSchema, ForgotPasswordSchema),
                (IResetPasswordSchema, ResetPasswordSchema),
                (IProfileSchema, ProfileSchema)]

    forms = [
        ILoginForm, IRegisterForm, IForgotPasswordForm, IResetPasswordForm,
        IProfileForm
    ]

    for iface, default in defaults:
        if not config.registry.queryUtility(iface):
            config.registry.registerUtility(default, iface)

    for form in forms:
        if not config.registry.queryUtility(form):
            config.registry.registerUtility(SubmitForm, form)

    def on_before_render(event):
        fn = render_flash_messages_from_queues
        event['render_flash_messages'] = lambda: fn(event['request'])

    config.add_subscriber(on_before_render, BeforeRender)

    config.include('horus.routes')
    config.scan(ignore=str('horus.tests'))
Esempio n. 5
0
def includeme(config):
    settings = config.registry.settings
    # str('user') returns a bytestring under Python 2 and a
    # unicode string under Python 3, which is what we need:
    config.set_request_property(get_user, str('user'), reify=True)
    config.set_root_factory(RootFactory)
    config.include('bag.web.pyramid.flash_msg')

    if not config.registry.queryUtility(IUserClass):
        user_class = get_class_from_config(settings, 'horus.user_class')
        config.registry.registerUtility(user_class, IUserClass)

    if not config.registry.queryUtility(IActivationClass):
        activation_class = get_class_from_config(settings,
                'horus.activation_class')
        config.registry.registerUtility(activation_class,
                IActivationClass)

    defaults = [
        (IUIStrings, UIStringsBase),
        (ILoginSchema, LoginSchema),
        (IRegisterSchema, RegisterSchema),
        (IForgotPasswordSchema, ForgotPasswordSchema),
        (IResetPasswordSchema, ResetPasswordSchema),
        (IProfileSchema, ProfileSchema)
    ]

    forms = [
        ILoginForm, IRegisterForm, IForgotPasswordForm,
        IResetPasswordForm, IProfileForm
    ]

    for iface, default in defaults:
        if not config.registry.queryUtility(iface):
            config.registry.registerUtility(default, iface)

    for form in forms:
        if not config.registry.queryUtility(form):
            config.registry.registerUtility(SubmitForm, form)
    config.include('horus.routes')
    config.scan(ignore=str('horus.tests'))