
¾«‘_€  ã               @   s²   d  Z  d d l m Z d d l m Z d d l m Z d d l m	 Z
 d d l m Z d d l m Z Gd	 d
 „  d
 e
 ƒ Z	 Gd d „  d e e	 ƒ Z Gd d „  d e e	 ƒ Z d S)zš
    flask.wrappers
    ~~~~~~~~~~~~~~

    Implements the WSGI wrappers (request and response).

    :copyright: 2010 Pallets
    :license: BSD-3-Clause
é    )Ú
BadRequest)ÚRequest)ÚResponse)Ú	JSONMixiné   )Újson)Úcurrent_appc               @   s"   e  Z d  Z e Z d d „  Z d S)r   c             C   s1   t  r$ t  j r$ t d j | ƒ ƒ ‚ t ƒ  ‚ d  S)Nz!Failed to decode JSON object: {0})r   Údebugr   Úformat)ÚselfÚe© r   ú//tmp/pip-build-5gj8f0j9/flask/flask/wrappers.pyÚon_json_loading_failed   s    z JSONMixin.on_json_loading_failedN)Ú__name__Ú
__module__Ú__qualname__r   Zjson_moduler   r   r   r   r   r      s   r   c               @   sj   e  Z d  Z d Z d Z d Z d Z e d d „  ƒ Z e d d „  ƒ Z	 e d d „  ƒ Z
 d	 d
 „  Z d S)r   aÎ  The request object used by default in Flask.  Remembers the
    matched endpoint and view arguments.

    It is what ends up as :class:`~flask.request`.  If you want to replace
    the request object used you can subclass this and set
    :attr:`~flask.Flask.request_class` to your subclass.

    The request object is a :class:`~werkzeug.wrappers.Request` subclass and
    provides all of the attributes Werkzeug defines plus a few Flask
    specific ones.
    Nc             C   s   t  r t  j d Sd S)z8Read-only view of the ``MAX_CONTENT_LENGTH`` config key.ZMAX_CONTENT_LENGTHN)r   Úconfig)r   r   r   r   Úmax_content_lengthA   s    zRequest.max_content_lengthc             C   s   |  j  d k	 r |  j  j Sd S)zêThe endpoint that matched the request.  This in combination with
        :attr:`view_args` can be used to reconstruct the same or a
        modified URL.  If an exception happened when matching, this will
        be ``None``.
        N)Úurl_ruleÚendpoint)r   r   r   r   r   G   s    zRequest.endpointc             C   s9   |  j  r5 d |  j  j k r5 |  j  j j d d ƒ d Sd S)z!The name of the current blueprintÚ.r   r   N)r   r   Úrsplit)r   r   r   r   Ú	blueprintQ   s    zRequest.blueprintc             C   sS   t  j |  ƒ t rO t j rO |  j d k rO |  j rO d d l m } | |  ƒ d  S)Nzmultipart/form-datar   )Úattach_enctype_error_multidict)ÚRequestBaseÚ_load_form_datar   r	   ÚmimetypeÚfilesZdebughelpersr   )r   r   r   r   r   r   W   s    	
zRequest._load_form_data)r   r   r   Ú__doc__r   Z	view_argsZrouting_exceptionÚpropertyr   r   r   r   r   r   r   r   r      s   
r   c                   s@   e  Z d  Z d Z d Z d d „  Z e ‡  f d d †  ƒ Z ‡  S)r   a¬  The response object that is used by default in Flask.  Works like the
    response object from Werkzeug but is set to have an HTML mimetype by
    default.  Quite often you don't have to create this object yourself because
    :meth:`~flask.Flask.make_response` will take care of that for you.

    If you want to replace the response object used you can subclass this and
    set :attr:`~flask.Flask.response_class` to your subclass.

    .. versionchanged:: 1.0
        JSON support is added to the response, like the request. This is useful
        when testing to get the test client response data as JSON.

    .. versionchanged:: 1.0

        Added :attr:`max_cookie_size`.
    z	text/htmlc             C   s
   |  j  ƒ  S)N)Úget_data)r   Úcacher   r   r   Ú_get_data_for_json{   s    zResponse._get_data_for_jsonc                s!   t  r t  j d St t |  ƒ j S)z£Read-only view of the :data:`MAX_COOKIE_SIZE` config key.

        See :attr:`~werkzeug.wrappers.BaseResponse.max_cookie_size` in
        Werkzeug's docs.
        ZMAX_COOKIE_SIZE)r   r   Úsuperr   Úmax_cookie_size)r   )Ú	__class__r   r   r%   ~   s    zResponse.max_cookie_size)r   r   r   r   Zdefault_mimetyper#   r    r%   r   r   )r&   r   r   g   s   r   N)r   Zwerkzeug.exceptionsr   Zwerkzeug.wrappersr   r   r   ZResponseBaseZwerkzeug.wrappers.jsonr   Z
_JSONMixinÚ r   Úglobalsr   r   r   r   r   Ú<module>
   s   
I