当前位置: 首页>>代码示例>>Python>>正文


Python pluginapi.get_config函数代码示例

本文整理汇总了Python中mediagoblin.tools.pluginapi.get_config函数的典型用法代码示例。如果您正苦于以下问题:Python get_config函数的具体用法?Python get_config怎么用?Python get_config使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了get_config函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: setup_plugin

def setup_plugin():
    config = pluginapi.get_config('mediagoblin.plugins.persona')

    routes = [
        ('mediagoblin.plugins.persona.login',
         '/auth/persona/login/',
         'mediagoblin.plugins.persona.views:login'),
        ('mediagoblin.plugins.persona.register',
         '/auth/persona/register/',
         'mediagoblin.plugins.persona.views:register'),
        ('mediagoblin.plugins.persona.edit',
         '/edit/persona/',
         'mediagoblin.plugins.persona.views:edit'),
        ('mediagoblin.plugins.persona.add',
         '/edit/persona/add/',
         'mediagoblin.plugins.persona.views:add')]

    pluginapi.register_routes(routes)
    pluginapi.register_template_path(os.path.join(PLUGIN_DIR, 'templates'))
    pluginapi.register_template_hooks(
        {'persona_end': 'mediagoblin/plugins/persona/persona_js_end.html',
         'persona_form': 'mediagoblin/plugins/persona/persona.html',
         'edit_link': 'mediagoblin/plugins/persona/edit_link.html',
         'login_link': 'mediagoblin/plugins/persona/login_link.html',
         'register_link': 'mediagoblin/plugins/persona/register_link.html'})
开发者ID:campadrenalin,项目名称:mediagoblin,代码行数:25,代码来源:__init__.py

示例2: extra_validation

def extra_validation(register_form):
    config = pluginapi.get_config('mediagoblin.plugins.lepturecaptcha')
    captcha_secret = config.get('CAPTCHA_SECRET_PHRASE')

    if 'captcha_response' in register_form:
        captcha_response = register_form.captcha_response.data
    if 'captcha_hash' in register_form:
        captcha_hash = register_form.captcha_hash.data
        if captcha_hash == u'':
            for raw_data in register_form.captcha_hash.raw_data:
                if raw_data != u'':
                    captcha_hash = raw_data
    if 'remote_address' in register_form:
        remote_address = register_form.remote_address.data
        if remote_address == u'':
            for raw_data in register_form.remote_address.raw_data:
                if raw_data != u'':
                    remote_address = raw_data

    captcha_challenge_passes = False

    if captcha_response and captcha_hash:
        captcha_response_hash = sha1(captcha_secret + captcha_response).hexdigest()
        captcha_challenge_passes = (captcha_response_hash == captcha_hash)

    if not captcha_challenge_passes:
        register_form.captcha_response.errors.append(
            _('Sorry, CAPTCHA attempt failed.'))
        _log.info('Failed registration CAPTCHA attempt from %r.', remote_address)
        _log.debug('captcha response is: %r', captcha_response)
        _log.debug('captcha hash is: %r', captcha_hash)
        _log.debug('captcha response hash is: %r', captcha_response_hash)

    return captcha_challenge_passes
开发者ID:ayleph,项目名称:mediagoblin-lepture_captcha,代码行数:34,代码来源:tools.py

示例3: setup_plugin

def setup_plugin():
    config = pluginapi.get_config('mediagoblin.plugins.openid')

    routes = [
        ('mediagoblin.plugins.openid.register',
         '/auth/openid/register/',
         'mediagoblin.plugins.openid.views:register'),
        ('mediagoblin.plugins.openid.login',
         '/auth/openid/login/',
         'mediagoblin.plugins.openid.views:login'),
        ('mediagoblin.plugins.openid.finish_login',
         '/auth/openid/login/finish/',
         'mediagoblin.plugins.openid.views:finish_login'),
        ('mediagoblin.plugins.openid.edit',
         '/edit/openid/',
         'mediagoblin.plugins.openid.views:start_edit'),
        ('mediagoblin.plugins.openid.finish_edit',
         '/edit/openid/finish/',
         'mediagoblin.plugins.openid.views:finish_edit'),
        ('mediagoblin.plugins.openid.delete',
         '/edit/openid/delete/',
         'mediagoblin.plugins.openid.views:delete_openid'),
        ('mediagoblin.plugins.openid.finish_delete',
         '/edit/openid/delete/finish/',
         'mediagoblin.plugins.openid.views:finish_delete')]

    pluginapi.register_routes(routes)
    pluginapi.register_template_path(os.path.join(PLUGIN_DIR, 'templates'))

    pluginapi.register_template_hooks(
        {'register_link': 'mediagoblin/plugins/openid/register_link.html',
         'login_link': 'mediagoblin/plugins/openid/login_link.html',
         'edit_link': 'mediagoblin/plugins/openid/edit_link.html'})
开发者ID:ausbin,项目名称:mediagoblin,代码行数:33,代码来源:__init__.py

示例4: setup_plugin

def setup_plugin():
    _log.info('Setting up lepturecaptcha...')

    config = pluginapi.get_config('mediagoblin.plugins.lepturecaptcha')
    if config:
        if config.get('CAPTCHA_SECRET_PHRASE') == 'changeme':
            configuration_error = 'You must configure the captcha secret phrase.'
            raise ImproperlyConfigured(configuration_error)

    pluginapi.register_template_path(os.path.join(PLUGIN_DIR, 'templates'))

    pluginapi.register_template_hooks(
        {'register_captcha': 'mediagoblin/plugins/lepturecaptcha/captcha_challenge.html'})

    # Create dummy request object to find register_form.
    environ = create_environ('/foo', 'http://localhost:8080/')
    request = Request(environ)
    register_form = pluginapi.hook_handle("auth_get_registration_form", request)
    del request

    # Add plugin-specific fields to register_form class.
    register_form_class = register_form.__class__
    register_form_class.captcha_response = captcha_forms.CaptchaStringField('CAPTCHA response', id='captcha_response', name='captcha_response')
    register_form_class.captcha_hash = wtforms.HiddenField('')
    register_form_class.remote_address = wtforms.HiddenField('')

    _log.info('Done setting up lepturecaptcha!')
开发者ID:ayleph,项目名称:mediagoblin-lepture_captcha,代码行数:27,代码来源:__init__.py

示例5: setup_plugin

def setup_plugin():
    config = pluginapi.get_config('mediagoblin.plugins.oauth')

    _log.info('Setting up OAuth...')
    _log.debug('OAuth config: {0}'.format(config))

    routes = [
       ('mediagoblin.plugins.oauth.authorize',
            '/oauth/authorize',
            'mediagoblin.plugins.oauth.views:authorize'),
        ('mediagoblin.plugins.oauth.authorize_client',
            '/oauth/client/authorize',
            'mediagoblin.plugins.oauth.views:authorize_client'),
        ('mediagoblin.plugins.oauth.access_token',
            '/oauth/access_token',
            'mediagoblin.plugins.oauth.views:access_token'),
        ('mediagoblin.plugins.oauth.list_connections',
            '/oauth/client/connections',
            'mediagoblin.plugins.oauth.views:list_connections'),
        ('mediagoblin.plugins.oauth.register_client',
            '/oauth/client/register',
            'mediagoblin.plugins.oauth.views:register_client'),
        ('mediagoblin.plugins.oauth.list_clients',
            '/oauth/client/list',
            'mediagoblin.plugins.oauth.views:list_clients')]

    pluginapi.register_routes(routes)
    pluginapi.register_template_path(os.path.join(PLUGIN_DIR, 'templates'))
开发者ID:imclab,项目名称:mediagoblin,代码行数:28,代码来源:__init__.py

示例6: search_results_view

def search_results_view(request, page):
    media_entries = None
    pagination = None
    form = indexedsearch.forms.SearchForm(request.form)

    config = pluginapi.get_config('indexedsearch')
    if config.get('SEARCH_LINK_STYLE') == 'form':
        form.show = False
    else:
        form.show = True

    query = None
    if request.method == 'GET' and 'q' in request.GET:
        query = request.GET['q']

    if query:
        engine = get_engine()
        result_ids = engine.search(query)

        if result_ids:
            matches = MediaEntry.query.filter(
                MediaEntry.id.in_(result_ids))
            pagination = Pagination(page, matches)
            media_entries = pagination()

    return render_to_response(
        request,
        'indexedsearch/results.html',
        {'media_entries': media_entries,
         'pagination': pagination,
         'form': form})
开发者ID:tofay,项目名称:mediagoblin-indexedsearch,代码行数:31,代码来源:views.py

示例7: setup_plugin

def setup_plugin():
    """Setup plugin by adding routes and templates to mediagoblin"""

    _log.info('Setting up routes and templates')
    config = pluginapi.get_config('indexedsearch')

    if config.get('USERS_ONLY'):
        view = 'user_search_results_view'
    else:
        view = 'search_results_view'

    routes = [
        ('indexedsearch',
         '/search/',
         'indexedsearch.views:' + view)]

    pluginapi.register_routes(routes)
    pluginapi.register_template_path(os.path.join(PLUGIN_DIR, 'templates'))

    search_link_style = config.get('SEARCH_LINK_STYLE')
    _log.debug("Search link style was specified as: %r", search_link_style)

    if search_link_style in ['button', 'link', 'none', 'form']:
        header_template = ('indexedsearch/search_link_%s.html' %
                           search_link_style)
    else:
        header_template = 'indexedsearch/search_link_form.html'

    pluginapi.register_template_hooks(
        {'header_extra': header_template})
开发者ID:tofay,项目名称:mediagoblin-indexedsearch,代码行数:30,代码来源:__init__.py

示例8: get_registration_form

def get_registration_form(request):
    config = pluginapi.get_config('mediagoblin.plugins.recaptcha2')
    return recaptcha2_forms.RegistrationForm(request.form,
                                             site_key=config.get('RECAPTCHA_SITE_KEY'),
                                             secret_key=config.get('RECAPTCHA_SECRET_KEY'),
                                             captcha={
                                                'ip_address': request.remote_addr,
                                             })
开发者ID:gsarkis,项目名称:mediagoblin-recaptcha2,代码行数:8,代码来源:__init__.py

示例9: setup_plugin

def setup_plugin():
    config = pluginapi.get_config('mediagoblin.plugins.geolocation')
    
    # Register the template path.
    pluginapi.register_template_path(os.path.join(PLUGIN_DIR, 'templates'))

    pluginapi.register_template_hooks(
        {"image_sideinfo": "mediagoblin/plugins/geolocation/map.html",
         "image_head": "mediagoblin/plugins/geolocation/map_js_head.html"})
开发者ID:RichoHan,项目名称:MediaGoblin,代码行数:9,代码来源:__init__.py

示例10: setup_plugin

def setup_plugin():
	_log.info("Plugin loading")
	config = get_config('uploadurl')
	if config:
		_log.info('%r' % config)
	else:
		_log.info("no config found continuing")

	register_routes(('upload', '/upload', 'uploadurl.views:upload_handler'))
开发者ID:sebastiansam55,项目名称:uploadurl,代码行数:9,代码来源:__init__.py

示例11: setup_plugin

def setup_plugin():
    global _setup_plugin_called

    _log.info('Sample plugin set up!')
    config = get_config('mediagoblin.plugins.sampleplugin')
    if config:
        _log.info('%r' % config)
    else:
        _log.info('There is no configuration set.')
    _setup_plugin_called += 1
开发者ID:3rdwiki,项目名称:mediagoblin,代码行数:10,代码来源:__init__.py

示例12: register

def register(request):
#    if request.method == 'GET':
#        return redirect(
#            request,
#            'mediagoblin.plugins.recaptcha.register')

    register_form = auth_forms.RegistrationForm(request.form)
    config = pluginapi.get_config('mediagoblin.plugins.recaptcha')

    recaptcha_protocol = ''
    if config['RECAPTCHA_USE_SSL']:
        recaptcha_protocol = 'https'
    else:
        recaptcha_protocol = 'http'
    _log.debug("Connecting to reCAPTCHA service via %r", recaptcha_protocol)

    if register_form.validate():
        recaptcha_challenge = request.form['recaptcha_challenge_field']
        recaptcha_response = request.form['recaptcha_response_field']
        _log.debug("response field is: %r", recaptcha_response)
        _log.debug("challenge field is: %r", recaptcha_challenge)
        response = captcha.submit(
            recaptcha_challenge,
            recaptcha_response,
            config.get('RECAPTCHA_PRIVATE_KEY'),
            request.remote_addr,
            )

        goblin = response.is_valid
        if response.error_code:
            _log.warning("reCAPTCHA error: %r", response.error_code)

        if goblin:
            user = register_user(request, register_form)

            if user:
                # redirect the user to their homepage... there will be a
                # message waiting for them to verify their email
                return redirect(
                    request, 'mediagoblin.user_pages.user_home',
                    user=user.username)

        else:
            messages.add_message(
                request,
                messages.WARNING,
                _('Sorry, captcha was incorrect. Please try again.'))

    return render_to_response(
        request,
        'mediagoblin/plugins/recaptcha/register.html',
        {'register_form': register_form,
         'post_url': request.urlgen('mediagoblin.plugins.recaptcha.register'),
         'recaptcha_public_key': config.get('RECAPTCHA_PUBLIC_KEY'),
         'recaptcha_protocol' : recaptcha_protocol})
开发者ID:goblinrefuge,项目名称:goblinrefuge-mediagoblin,代码行数:55,代码来源:views.py

示例13: setup_plugin

def setup_plugin():
    global config 
    config = pluginapi.get_config('advanced-sampleplugin')
    if config:
        _log.info('%r' % config)
    else:
        _log.info('There is no configuration set.')
    
    pluginapi.register_template_path(os.path.join(PLUGIN_DIR, 'templates'))

    pluginapi.register_template_hooks(
        {"persona_end": "mediagoblin/advanced-sampleplugin/template.html"})
开发者ID:cmichi,项目名称:mediagoblin-plugins,代码行数:12,代码来源:__init__.py

示例14: setup_plugin

def setup_plugin():
    config = pluginapi.get_config("mediagoblin.plugins.geolocation")

    # Register the template path.
    pluginapi.register_template_path(os.path.join(PLUGIN_DIR, "templates"))

    pluginapi.register_template_hooks(
        {
            "location_info": "mediagoblin/plugins/geolocation/map.html",
            "location_head": "mediagoblin/plugins/geolocation/map_js_head.html",
        }
    )
开发者ID:tofay,项目名称:mediagoblin,代码行数:12,代码来源:__init__.py

示例15: setup_plugin

def setup_plugin():
	_log.info("Starting podcaster")
	config = get_config('podcast')
	if config:
		_log.info("CONFIG FOUND")
	else:
		_log.info("CONFIG NOT FOUND")

	register_routes([('makeapodcast','/makeapodcast.html','podcast.views:register_podcast'),
		('podcast.rssfeed', '/u/<string:user>/podcast', 'podcast.views:get_podcasts'),
		('podcast.createpodcast','/podcast/create','podcast.views:create_podcast'),
		('podcast.listpodcast', '/u/<string:user>/listpodcast', 'podcast.views:list_podcast')])
	register_template_path(os.path.join(PLUGIN_DIR, 'templates'))
开发者ID:sebastiansam55,项目名称:gmgpodcast,代码行数:13,代码来源:__init__.py


注:本文中的mediagoblin.tools.pluginapi.get_config函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。