python类get_request()的实例源码

i18n.py 文件源码 项目:webapp2 作者: GoogleCloudPlatform 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def get_i18n(factory=I18n, key=_i18n_registry_key, request=None):
    """Returns an instance of :class:`I18n` from the request registry.

    It'll try to get it from the current request registry, and if it is not
    registered it'll be instantiated and registered. A second call to this
    function will return the same instance.

    :param factory:
        The callable used to build and register the instance if it is not yet
        registered. The default is the class :class:`I18n` itself.
    :param key:
        The key used to store the instance in the registry. A default is used
        if it is not set.
    :param request:
        A :class:`webapp2.Request` instance used to store the instance. The
        active request is used if it is not set.
    """
    request = request or webapp2.get_request()
    i18n = request.registry.get(key)
    if not i18n:
        i18n = request.registry[key] = factory(request)

    return i18n
sessions.py 文件源码 项目:webapp2 作者: GoogleCloudPlatform 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def get_store(factory=SessionStore, key=_registry_key, request=None):
    """Returns an instance of :class:`SessionStore` from the request registry.

    It'll try to get it from the current request registry, and if it is not
    registered it'll be instantiated and registered. A second call to this
    function will return the same instance.

    :param factory:
        The callable used to build and register the instance if it is not yet
        registered. The default is the class :class:`SessionStore` itself.
    :param key:
        The key used to store the instance in the registry. A default is used
        if it is not set.
    :param request:
        A :class:`webapp2.Request` instance used to store the instance. The
        active request is used if it is not set.
    """
    request = request or webapp2.get_request()
    store = request.registry.get(key)
    if not store:
        store = request.registry[key] = factory(request)

    return store
sessions.py 文件源码 项目:webapp2 作者: GoogleCloudPlatform 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def set_store(store, key=_registry_key, request=None):
    """Sets an instance of :class:`SessionStore` in the request registry.

    :param store:
        An instance of :class:`SessionStore`.
    :param key:
        The key used to retrieve the instance from the registry. A default
        is used if it is not set.
    :param request:
        A :class:`webapp2.Request` instance used to retrieve the instance. The
        active request is used if it is not set.
    """
    request = request or webapp2.get_request()
    request.registry[key] = store


# Don't need to import it. :)
auth.py 文件源码 项目:webapp2 作者: GoogleCloudPlatform 项目源码 文件源码 阅读 30 收藏 0 点赞 0 评论 0
def get_auth(factory=Auth, key=_auth_registry_key, request=None):
    """Returns an instance of :class:`Auth` from the request registry.

    It'll try to get it from the current request registry, and if it is not
    registered it'll be instantiated and registered. A second call to this
    function will return the same instance.

    :param factory:
        The callable used to build and register the instance if it is not yet
        registered. The default is the class :class:`Auth` itself.
    :param key:
        The key used to store the instance in the registry. A default is used
        if it is not set.
    :param request:
        A :class:`webapp2.Request` instance used to store the instance. The
        active request is used if it is not set.
    """
    request = request or webapp2.get_request()
    auth = request.registry.get(key)
    if not auth:
        auth = request.registry[key] = factory(request)

    return auth
i18n.py 文件源码 项目:blockhooks 作者: EthereumWebhooks 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def get_i18n(factory=I18n, key=_i18n_registry_key, request=None):
    """Returns an instance of :class:`I18n` from the request registry.

    It'll try to get it from the current request registry, and if it is not
    registered it'll be instantiated and registered. A second call to this
    function will return the same instance.

    :param factory:
        The callable used to build and register the instance if it is not yet
        registered. The default is the class :class:`I18n` itself.
    :param key:
        The key used to store the instance in the registry. A default is used
        if it is not set.
    :param request:
        A :class:`webapp2.Request` instance used to store the instance. The
        active request is used if it is not set.
    """
    request = request or webapp2.get_request()
    i18n = request.registry.get(key)
    if not i18n:
        i18n = request.registry[key] = factory(request)

    return i18n
sessions.py 文件源码 项目:blockhooks 作者: EthereumWebhooks 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def get_store(factory=SessionStore, key=_registry_key, request=None):
    """Returns an instance of :class:`SessionStore` from the request registry.

    It'll try to get it from the current request registry, and if it is not
    registered it'll be instantiated and registered. A second call to this
    function will return the same instance.

    :param factory:
        The callable used to build and register the instance if it is not yet
        registered. The default is the class :class:`SessionStore` itself.
    :param key:
        The key used to store the instance in the registry. A default is used
        if it is not set.
    :param request:
        A :class:`webapp2.Request` instance used to store the instance. The
        active request is used if it is not set.
    """
    request = request or webapp2.get_request()
    store = request.registry.get(key)
    if not store:
        store = request.registry[key] = factory(request)

    return store
sessions.py 文件源码 项目:blockhooks 作者: EthereumWebhooks 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
def set_store(store, key=_registry_key, request=None):
    """Sets an instance of :class:`SessionStore` in the request registry.

    :param store:
        An instance of :class:`SessionStore`.
    :param key:
        The key used to retrieve the instance from the registry. A default
        is used if it is not set.
    :param request:
        A :class:`webapp2.Request` instance used to retrieve the instance. The
        active request is used if it is not set.
    """
    request = request or webapp2.get_request()
    request.registry[key] = store


# Don't need to import it. :)
auth.py 文件源码 项目:blockhooks 作者: EthereumWebhooks 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def get_auth(factory=Auth, key=_auth_registry_key, request=None):
    """Returns an instance of :class:`Auth` from the request registry.

    It'll try to get it from the current request registry, and if it is not
    registered it'll be instantiated and registered. A second call to this
    function will return the same instance.

    :param factory:
        The callable used to build and register the instance if it is not yet
        registered. The default is the class :class:`Auth` itself.
    :param key:
        The key used to store the instance in the registry. A default is used
        if it is not set.
    :param request:
        A :class:`webapp2.Request` instance used to store the instance. The
        active request is used if it is not set.
    """
    request = request or webapp2.get_request()
    auth = request.registry.get(key)
    if not auth:
        auth = request.registry[key] = factory(request)

    return auth
idtokenauth.py 文件源码 项目:sndlatr 作者: Schibum 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def get_current_user():
    """  GAE compatibility method. """
    request = webapp2.get_request()
    app = webapp2.get_app()
    audience = app.config.get('idtoken_audience')
    if not audience:
        raise Exception('idtoken_audience not configured')
    token = request.headers.get('x-w69b-idtoken')
    return _user_from_token(token, audience)
zones.py 文件源码 项目:professional-services 作者: GoogleCloudPlatform 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
def registry(self):
        """Return request registry."""
        try:
            return webapp2.get_request().registry
        except AssertionError:
            return {}
i18n.py 文件源码 项目:webapp2 作者: GoogleCloudPlatform 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def set_i18n(i18n, key=_i18n_registry_key, request=None):
    """Sets an instance of :class:`I18n` in the request registry.

    :param store:
        An instance of :class:`I18n`.
    :param key:
        The key used to retrieve the instance from the registry. A default
        is used if it is not set.
    :param request:
        A :class:`webapp2.Request` instance used to retrieve the instance. The
        active request is used if it is not set.
    """
    request = request or webapp2.get_request()
    request.registry[key] = i18n
mimerender.py 文件源码 项目:oa_qian 作者: sunqb 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def _get_request_parameter(self, key, default=None):
            return webapp2.get_request().get(key, default_value=default)
mimerender.py 文件源码 项目:oa_qian 作者: sunqb 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def _get_accept_header(self, default=None):
            return webapp2.get_request().headers.get('Accept', default)
mimerender.py 文件源码 项目:oa_qian 作者: sunqb 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def _set_context_var(self, key, value):
            setattr(webapp2.get_request(), key, value)
mimerender.py 文件源码 项目:oa_qian 作者: sunqb 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
def _clear_context_var(self, key):
            delattr(webapp2.get_request(), key)
mimerender.py 文件源码 项目:oa_qian 作者: sunqb 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def _make_response(self, content, headers, status):
            response = webapp2.get_request().response
            response.status = status
            for k, v in headers:
                response.headers[k] = v
            response.write(content)
i18n.py 文件源码 项目:blockhooks 作者: EthereumWebhooks 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def set_i18n(i18n, key=_i18n_registry_key, request=None):
    """Sets an instance of :class:`I18n` in the request registry.

    :param store:
        An instance of :class:`I18n`.
    :param key:
        The key used to retrieve the instance from the registry. A default
        is used if it is not set.
    :param request:
        A :class:`webapp2.Request` instance used to retrieve the instance. The
        active request is used if it is not set.
    """
    request = request or webapp2.get_request()
    request.registry[key] = i18n


问题


面经


文章

微信
公众号

扫码关注公众号