當前位置: 首頁>>代碼示例>>Python>>正文


Python request.blueprint方法代碼示例

本文整理匯總了Python中flask.request.blueprint方法的典型用法代碼示例。如果您正苦於以下問題:Python request.blueprint方法的具體用法?Python request.blueprint怎麽用?Python request.blueprint使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在flask.request的用法示例。


在下文中一共展示了request.blueprint方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: json

# 需要導入模塊: from flask import request [as 別名]
# 或者: from flask.request import blueprint [as 別名]
def json(self):
        unit = [('id', self._id), ('name', self.name),
                ('description', self.description),
                ('expansion', self.expansion),
                ('age', self.age),
                ('created_in',
                '{}structure/{}'.format(request.url_root + request.blueprint,
                                        self.format_name_to_query(self.structure.first().name))
                 if self.structure.first() else self.created_in),
                ('cost', json.loads(self.cost.replace(";", ","))),
                ('build_time', self.build_time),
                ('reload_time', self.reload_time),
                ('attack_delay', self.attack_delay),
                ('movement_rate', self.movement_rate),
                ('line_of_sight', self.line_of_sight),
                ('hit_points', self.hit_points),
                ('range', int(self.range) if self.range.isdigit() else self.range),
                ('attack', self.attack), ('armor', self.armor),
                ('attack_bonus', self.attack_bonus.split(";") if self.attack_bonus else None),
                ('armor_bonus', self.armor_bonus.split(";") if self.armor_bonus else None),
                ('search_radius', self.search_radius),
                ('accuracy', self.accuracy),
                ('blast_radius', self.blast_radius)]
        return OrderedDict([(k, v) for k, v in unit if v]) 
開發者ID:aalises,項目名稱:age-of-empires-II-api,代碼行數:26,代碼來源:unit.py

示例2: json

# 需要導入模塊: from flask import request [as 別名]
# 或者: from flask.request import blueprint [as 別名]
def json(self):
        civilization = [('id', self._id),
                        ('name', self.name),
                        ('expansion', self.expansion),
                        ('army_type', self.army_type),
                        ('unique_unit', self.parse_array_field(self.unique_unit)
                         if not self.unit.first()
                         else ['{}unit/{}'.format(request.url_root + request.blueprint,
                                                  self.format_name_to_query(self.unit.first().name))]
                         ),
                        ('unique_tech', self.parse_array_field(self.unique_tech)
                         if not self.technology.first()
                         else ['{}technology/{}'.format(request.url_root + request.blueprint,
                               self.format_name_to_query(self.technology.first().name))]
                         ),
                        ('team_bonus', self.team_bonus),
                        ('civilization_bonus', self.civilization_bonus.split(";"))
                        ]
        return OrderedDict(civilization) 
開發者ID:aalises,項目名稱:age-of-empires-II-api,代碼行數:21,代碼來源:civilization.py

示例3: map_to_resource_url

# 需要導入模塊: from flask import request [as 別名]
# 或者: from flask.request import blueprint [as 別名]
def map_to_resource_url(self):
        out = []
        for item in self.applies_to.split(';'):
            unit = get_model('units').query.filter_by(name=item).first()
            structure = get_model('structures').query.filter_by(name=item).first()
            civilization = get_model('civilizations').query.filter_by(name=item).first()

            if unit:
                out.append('{}unit/{}'.format(request.url_root + request.blueprint, self.format_name_to_query(unit.name)))
            elif structure:
                out.append('{}structure/{}'.format(request.url_root + request.blueprint, self.format_name_to_query(structure.name)))
            elif civilization:
                out.append('{}civilization/{}'.format(request.url_root + request.blueprint, self.format_name_to_query(civilization.name)))
            else:
                out.append(item)
        return out 
開發者ID:aalises,項目名稱:age-of-empires-II-api,代碼行數:18,代碼來源:technology.py

示例4: _get_event_tracking_params

# 需要導入模塊: from flask import request [as 別名]
# 或者: from flask.request import blueprint [as 別名]
def _get_event_tracking_params(self):
        site_id_events = PiwikPlugin.settings.get('site_id_events')
        if not self.settings.get('enabled_for_events') or not site_id_events:
            return {}
        params = {'site_id_events': site_id_events}
        if request.blueprint in ('event', 'events', 'contributions') and 'confId' in request.view_args:
            if not unicode(request.view_args['confId']).isdigit():
                return {}
            params['event_id'] = request.view_args['confId']
            contrib_id = request.view_args.get('contrib_id')
            if contrib_id is not None and unicode(contrib_id).isdigit():
                contribution = Contribution.find_first(event_id=params['event_id'], id=contrib_id)
                if contribution:
                    cid = (contribution.legacy_mapping.legacy_contribution_id if contribution.legacy_mapping
                           else contribution.id)
                    params['contrib_id'] = '{}t{}'.format(contribution.event_id, cid)
        return params 
開發者ID:indico,項目名稱:indico-plugins,代碼行數:19,代碼來源:plugin.py

示例5: exempt

# 需要導入模塊: from flask import request [as 別名]
# 或者: from flask.request import blueprint [as 別名]
def exempt(self, obj):
        """
        decorator to mark a view or all views in a blueprint as exempt from
        rate limits.
        """
        if not isinstance(obj, Blueprint):
            name = "%s.%s" % (obj.__module__, obj.__name__)

            @wraps(obj)
            def __inner(*a, **k):
                return obj(*a, **k)

            self._exempt_routes.add(name)
            return __inner
        else:
            self._blueprint_exempt.add(obj.name) 
開發者ID:alisaifee,項目名稱:flask-limiter,代碼行數:18,代碼來源:extension.py

示例6: parse_array_field

# 需要導入模塊: from flask import request [as 別名]
# 或者: from flask.request import blueprint [as 別名]
def parse_array_field(self, field):
            out = []
            for item in [x for x in field.split(";")]:
                unit = get_model('units').query.filter_by(name=item).first()
                technology = get_model('technologies').query.filter_by(name=item).first()
                if unit:
                    out.append('{}unit/{}'.format(request.url_root + request.blueprint,
                                                  self.format_name_to_query(unit.name)))
                elif technology:
                    out.append('{}technology/{}'.format(request.url_root + request.blueprint,
                                                        self.format_name_to_query(technology.name)))
            return out 
開發者ID:aalises,項目名稱:age-of-empires-II-api,代碼行數:14,代碼來源:civilization.py

示例7: json

# 需要導入模塊: from flask import request [as 別名]
# 或者: from flask.request import blueprint [as 別名]
def json(self):
        technology = [('id', self._id),
                      ('name', self.name),
                      ('description', self.description),
                      ('expansion', self.expansion),
                      ('age', self.age),
                      ('develops_in',
                      '{}structure/{}'.format(request.url_root + request.blueprint, self.format_name_to_query(self.structure.first().name))
                       if self.structure.first() else self.develops_in),
                      ('cost', json.loads(self.cost.replace(";", ","))),
                      ('build_time', self.build_time),
                      ('applies_to', self.map_to_resource_url() if self.applies_to else None),
                      ]
        return OrderedDict([(k, v) for k, v in technology if v]) 
開發者ID:aalises,項目名稱:age-of-empires-II-api,代碼行數:16,代碼來源:technology.py

示例8: exempt

# 需要導入模塊: from flask import request [as 別名]
# 或者: from flask.request import blueprint [as 別名]
def exempt(self, view):
        """Mark a view or blueprint to be excluded from CSRF protection.

        ::

            @app.route('/some-view', methods=['POST'])
            @csrf.exempt
            def some_view():
                ...

        ::

            bp = Blueprint(...)
            csrf.exempt(bp)

        """

        if isinstance(view, Blueprint):
            self._exempt_blueprints.add(view.name)
            return view

        if isinstance(view, string_types):
            view_location = view
        else:
            view_location = '%s.%s' % (view.__module__, view.__name__)

        self._exempt_views.add(view_location)
        return view 
開發者ID:liantian-cn,項目名稱:RSSNewsGAE,代碼行數:30,代碼來源:csrf.py

示例9: _add_category_search_box

# 需要導入模塊: from flask import request [as 別名]
# 或者: from flask.request import blueprint [as 別名]
def _add_category_search_box(self, category, **kwargs):
        if request.blueprint != 'plugin_search':
            form = self.engine_plugin.search_form(prefix='search-', csrf_enabled=False)
            return render_engine_or_search_template('searchbox_category.html', category=category, form=form) 
開發者ID:indico,項目名稱:indico-plugins,代碼行數:6,代碼來源:plugin.py

示例10: _perform_global_filters

# 需要導入模塊: from flask import request [as 別名]
# 或者: from flask.request import blueprint [as 別名]
def _perform_global_filters() -> None:
    ledger = getattr(g, "ledger", None)
    if ledger:
        # check (and possibly reload) source file
        if request.blueprint != "json_api":
            ledger.changed()

        ledger.filter(
            account=request.args.get("account"),
            filter=request.args.get("filter"),
            time=request.args.get("time"),
        ) 
開發者ID:beancount,項目名稱:fava,代碼行數:14,代碼來源:application.py

示例11: _is_api

# 需要導入模塊: from flask import request [as 別名]
# 或者: from flask.request import blueprint [as 別名]
def _is_api(request):
    ''' Checks if the error comes from the api '''
    return request.blueprint == 'api' or 'api' in request.url 
開發者ID:sdss,項目名稱:marvin,代碼行數:5,代碼來源:error_handlers.py

示例12: template

# 需要導入模塊: from flask import request [as 別名]
# 或者: from flask.request import blueprint [as 別名]
def template(template_name, *dependency_urls, **initial_data):
    # find and load the template, based on the current request
    if request.blueprint:
        parent = current_app.blueprints[request.blueprint]
    else:
        parent = current_app
    if not parent.has_static_folder:
        raise RuntimeError("No static folder for angular template")
    template_path = os.path.join(parent.static_folder, template_name)
    template = open(template_path).read().decode('utf-8')

    # calculate the stylesheet and script links, based on suffix
    stylesheets = [u for u in dependency_urls if u.endswith('.css')]
    scripts = [u for u in dependency_urls if u.endswith('.js')]
    scripts.append(url_for('static', filename='js/relengapi.js'))
    if set(dependency_urls) - set(stylesheets) - set(scripts):
        raise RuntimeError("dependency_urls must all be .css and .js files")

    # include info on the current user
    user = {}
    user['permissions'] = [permissions.JsonPermission(name='.'.join(prm), doc=prm.__doc__)
                           for prm in current_user.permissions]
    user['type'] = current_user.type
    if current_user.type == 'human':
        user['authenticated_email'] = current_user.authenticated_email
    initial_data['user'] = user

    # include the full list of available permissions
    initial_data['perms'] = {str(prm): doc for prm, doc in p}

    return render_template('angular.html',
                           template=template,
                           stylesheets=stylesheets,
                           scripts=scripts,
                           initial_data=initial_data) 
開發者ID:mozilla,項目名稱:build-relengapi,代碼行數:37,代碼來源:angular.py

示例13: __init__

# 需要導入模塊: from flask import request [as 別名]
# 或者: from flask.request import blueprint [as 別名]
def __init__(self, app):
        self.extra_head_content = []

        @app.context_processor
        def _context_processor():
            if request.blueprint:
                blueprint = current_app.blueprints[request.blueprint]
            else:
                blueprint = current_app.blueprints['base']
            return {
                'blueprint': blueprint,
                'layout_extra_head_content': self.extra_head_content,
            } 
開發者ID:mozilla,項目名稱:build-relengapi,代碼行數:15,代碼來源:layout.py

示例14: init_app

# 需要導入模塊: from flask import request [as 別名]
# 或者: from flask.request import blueprint [as 別名]
def init_app(self, app):
        self._app = app
        app.jinja_env.globals['csrf_token'] = generate_csrf
        app.config.setdefault(
            'WTF_CSRF_HEADERS', ['X-CSRFToken', 'X-CSRF-Token']
        )
        app.config.setdefault('WTF_CSRF_SSL_STRICT', True)
        app.config.setdefault('WTF_CSRF_ENABLED', True)
        app.config.setdefault('WTF_CSRF_CHECK_DEFAULT', True)
        app.config.setdefault('WTF_CSRF_METHODS', ['POST', 'PUT', 'PATCH'])

        # expose csrf_token as a helper in all templates
        @app.context_processor
        def csrf_token():
            return dict(csrf_token=generate_csrf)

        if not app.config['WTF_CSRF_ENABLED']:
            return

        if not app.config['WTF_CSRF_CHECK_DEFAULT']:
            return

        @app.before_request
        def _csrf_protect():
            # many things come from django.middleware.csrf
            if request.method not in app.config['WTF_CSRF_METHODS']:
                return

            if self._exempt_views or self._exempt_blueprints:
                if not request.endpoint:
                    return

                view = app.view_functions.get(request.endpoint)
                if not view:
                    return

                dest = '%s.%s' % (view.__module__, view.__name__)
                if dest in self._exempt_views:
                    return
                if request.blueprint in self._exempt_blueprints:
                    return

            self.protect() 
開發者ID:jpush,項目名稱:jbox,代碼行數:45,代碼來源:csrf.py

示例15: init_app

# 需要導入模塊: from flask import request [as 別名]
# 或者: from flask.request import blueprint [as 別名]
def init_app(self, app):
        app.extensions['csrf'] = self

        app.config.setdefault('WTF_CSRF_ENABLED', True)
        app.config.setdefault('WTF_CSRF_CHECK_DEFAULT', True)
        app.config['WTF_CSRF_METHODS'] = set(app.config.get(
            'WTF_CSRF_METHODS', ['POST', 'PUT', 'PATCH', 'DELETE']
        ))
        app.config.setdefault('WTF_CSRF_FIELD_NAME', 'csrf_token')
        app.config.setdefault(
            'WTF_CSRF_HEADERS', ['X-CSRFToken', 'X-CSRF-Token']
        )
        app.config.setdefault('WTF_CSRF_TIME_LIMIT', 3600)
        app.config.setdefault('WTF_CSRF_SSL_STRICT', True)

        app.jinja_env.globals['csrf_token'] = generate_csrf
        app.context_processor(lambda: {'csrf_token': generate_csrf})

        @app.before_request
        def csrf_protect():
            if not app.config['WTF_CSRF_ENABLED']:
                return

            if not app.config['WTF_CSRF_CHECK_DEFAULT']:
                return

            if request.method not in app.config['WTF_CSRF_METHODS']:
                return

            if not request.endpoint:
                return

            view = app.view_functions.get(request.endpoint)

            if not view:
                return

            if request.blueprint in self._exempt_blueprints:
                return

            dest = '%s.%s' % (view.__module__, view.__name__)

            if dest in self._exempt_views:
                return

            self.protect() 
開發者ID:liantian-cn,項目名稱:RSSNewsGAE,代碼行數:48,代碼來源:csrf.py


注:本文中的flask.request.blueprint方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。