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


Python webapp2.get_request方法代碼示例

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


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

示例1: cache

# 需要導入模塊: import webapp2 [as 別名]
# 或者: from webapp2 import get_request [as 別名]
def cache(self):
    """Get the cache backing."""
    request = webapp2.get_request()
    if not request:
      # Not a request (e.g. in a unit test). Should not happen in production.
      logs.log_error('No request found for cache.')
      return None

    key = '__cache:' + self._cache_key

    backing = getattr(request, key, None)
    if backing is None:
      backing = collections.OrderedDict()
      setattr(request, key, backing)

    return backing 
開發者ID:google,項目名稱:clusterfuzz,代碼行數:18,代碼來源:request_cache.py

示例2: _add_appengine_trace

# 需要導入模塊: import webapp2 [as 別名]
# 或者: from webapp2 import get_request [as 別名]
def _add_appengine_trace(extras):
  """Add App Engine tracing information."""
  if not _is_running_on_app_engine():
    return

  import webapp2

  try:
    request = webapp2.get_request()
    if not request:
      return
  except Exception:
    # FIXME: Find a way to add traces in threads. Skip adding for now, as
    # otherwise, we hit an exception "Request global variable is not set".
    return

  trace_header = request.headers.get('X-Cloud-Trace-Context')
  if not trace_header:
    return

  project_id = os.getenv('APPLICATION_ID')
  trace_id = trace_header.split('/')[0]
  extras['logging.googleapis.com/trace'] = (
      'projects/{project_id}/traces/{trace_id}').format(
          project_id=project_id, trace_id=trace_id) 
開發者ID:google,項目名稱:clusterfuzz,代碼行數:27,代碼來源:logs.py

示例3: get_auth

# 需要導入模塊: import webapp2 [as 別名]
# 或者: from webapp2 import get_request [as 別名]
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 
開發者ID:google,項目名稱:googleapps-message-recall,代碼行數:25,代碼來源:auth.py

示例4: get_i18n

# 需要導入模塊: import webapp2 [as 別名]
# 或者: from webapp2 import get_request [as 別名]
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 
開發者ID:google,項目名稱:googleapps-message-recall,代碼行數:25,代碼來源:i18n.py

示例5: get_store

# 需要導入模塊: import webapp2 [as 別名]
# 或者: from webapp2 import get_request [as 別名]
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 
開發者ID:google,項目名稱:googleapps-message-recall,代碼行數:25,代碼來源:sessions.py

示例6: get_current_request

# 需要導入模塊: import webapp2 [as 別名]
# 或者: from webapp2 import get_request [as 別名]
def get_current_request():
  """Get the current request."""
  return webapp2.get_request() 
開發者ID:google,項目名稱:clusterfuzz,代碼行數:5,代碼來源:auth.py

示例7: get_current_user

# 需要導入模塊: import webapp2 [as 別名]
# 或者: from webapp2 import get_request [as 別名]
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) 
開發者ID:Schibum,項目名稱:sndlatr,代碼行數:11,代碼來源:idtokenauth.py

示例8: set_auth

# 需要導入模塊: import webapp2 [as 別名]
# 或者: from webapp2 import get_request [as 別名]
def set_auth(auth, key=_auth_registry_key, request=None):
    """Sets an instance of :class:`Auth` in the request registry.

    :param auth:
        An instance of :class:`Auth`.
    :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] = auth 
開發者ID:google,項目名稱:googleapps-message-recall,代碼行數:16,代碼來源:auth.py

示例9: set_i18n

# 需要導入模塊: import webapp2 [as 別名]
# 或者: from webapp2 import get_request [as 別名]
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 
開發者ID:google,項目名稱:googleapps-message-recall,代碼行數:16,代碼來源:i18n.py

示例10: _get_request_parameter

# 需要導入模塊: import webapp2 [as 別名]
# 或者: from webapp2 import get_request [as 別名]
def _get_request_parameter(self, key, default=None):
            return webapp2.get_request().get(key, default_value=default) 
開發者ID:yfauser,項目名稱:planespotter,代碼行數:4,代碼來源:mimerender.py

示例11: _get_accept_header

# 需要導入模塊: import webapp2 [as 別名]
# 或者: from webapp2 import get_request [as 別名]
def _get_accept_header(self, default=None):
            return webapp2.get_request().headers.get('Accept', default) 
開發者ID:yfauser,項目名稱:planespotter,代碼行數:4,代碼來源:mimerender.py

示例12: _set_context_var

# 需要導入模塊: import webapp2 [as 別名]
# 或者: from webapp2 import get_request [as 別名]
def _set_context_var(self, key, value):
            setattr(webapp2.get_request(), key, value) 
開發者ID:yfauser,項目名稱:planespotter,代碼行數:4,代碼來源:mimerender.py

示例13: _clear_context_var

# 需要導入模塊: import webapp2 [as 別名]
# 或者: from webapp2 import get_request [as 別名]
def _clear_context_var(self, key):
            delattr(webapp2.get_request(), key) 
開發者ID:yfauser,項目名稱:planespotter,代碼行數:4,代碼來源:mimerender.py

示例14: _make_response

# 需要導入模塊: import webapp2 [as 別名]
# 或者: from webapp2 import get_request [as 別名]
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) 
開發者ID:yfauser,項目名稱:planespotter,代碼行數:8,代碼來源:mimerender.py

示例15: registry

# 需要導入模塊: import webapp2 [as 別名]
# 或者: from webapp2 import get_request [as 別名]
def registry(self):
        """Return request registry."""
        try:
            return webapp2.get_request().registry
        except AssertionError:
            return {} 
開發者ID:GoogleCloudPlatform,項目名稱:professional-services,代碼行數:8,代碼來源:zones.py


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