
    +ho                        d dl mZ d dlmZmZ d dlmZmZ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 d d	lmZmZmZmZmZ d d
lmZ d dlmZmZmZ d dl m!Z! d dl"Z"d dl#m$Z$ d dl%Z%	 d dl&m'Z' dZ*dZ+d Z	d Z,d Z-de!fgZ. G d de/      Z0 G d de      Z1ddZ2 G d de/      Z3 G d de/      Z4y# e($ r	 d dl)m'Z' Y Pw xY w)     )absolute_import)wrapspartial)requesturl_forcurrent_app)abort)make_response)
MethodView)got_request_exception)Headers)HTTPExceptionMethodNotAllowedNotFoundNotAcceptableInternalServerError)Response)http_status_messageunpackOrderedDict)output_jsonN)
MethodType)MappingPROPAGATE_EXCEPTIONS)ApiResourcemarshalmarshal_withmarshal_with_fieldr	   c                 d    	 t        |        y# t        $ r}t        |      r||_         d}~ww xY w)zRaise a HTTPException for the given http_status_code. Attach any keyword
    arguments to the exception for later processing.
    N)original_flask_abortr   lendata)http_status_codekwargses      I/var/www/html/venv/lib/python3.12/site-packages/flask_restful/__init__.pyr	   r	      s1    
-. v;AFs    	/*/c                 ~    | j                   j                  t        d      }|| j                  xs | j                  S |S )uI  Handle Flask's propagate_exceptions.

    If propagate_exceptions is set to True then the exceptions are re-raised rather than being handled
    by the app’s error handlers.

    The default value for Flask's app.config['PROPAGATE_EXCEPTIONS'] is None. In this case return a sensible
    value: self.testing or self.debug.
    F)configget_PROPAGATE_EXCEPTIONStestingdebug)apppropagate_exceptionss     r'   _get_propagate_exceptions_boolr0   '   s9     ::>>*?G#{{'cii'    c                 ~    t        |       }t        |t              s"|rt        j                         \  }}}||u r |y y N)r0   
isinstancer   sysexc_info)r.   r&   r/   exc_type	exc_valuetbs         r'   )_handle_flask_propagate_exceptions_configr:   6   sD    9#>a',@"%,,.)R>G -A'r1   application/jsonc                       e Zd ZdZ	 	 	 	 ddZd Zd Zedd       Zd Z	d Z
d	 Zd
 Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zy)r   a  
    The main entry point for the application.
    You need to initialize it with a Flask Application: ::

    >>> app = Flask(__name__)
    >>> api = restful.Api(app)

    Alternatively, you can use :meth:`init_app` to set the Flask application
    after it has been constructed.

    :param app: the Flask application object
    :type app: flask.Flask or flask.Blueprint
    :param prefix: Prefix all routes with a value, eg v1 or 2010-04-01
    :type prefix: str
    :param default_mediatype: The default media type to return
    :type default_mediatype: str
    :param decorators: Decorators to attach to every resource
    :type decorators: list
    :param catch_all_404s: Use :meth:`handle_error`
        to handle 404 errors throughout your app
    :param serve_challenge_on_401: Whether to serve a challenge response to
        clients on receiving 401. This usually leads to a username/password
        popup in web browsers.
    :param url_part_order: A string that controls the order that the pieces
        of the url are concatenated when the full url is constructed.  'b'
        is the blueprint (or blueprint registration) prefix, 'a' is the api
        prefix, and 'e' is the path component the endpoint is added with
    :type catch_all_404s: bool
    :param errors: A dictionary to define a custom response for each
        exception or error raised during a request
    :type errors: dict

    Nc	                 8   t        t              | _        i | _        || _        || _        |r|ng | _        || _        || _        || _	        |xs i | _
        d | _        t               | _        g | _        d | _        d | _        ||| _        | j#                  |       y y r3   )r   DEFAULT_REPRESENTATIONSrepresentationsurlsprefixdefault_mediatype
decoratorscatch_all_404sserve_challenge_on_401url_part_ordererrorsblueprint_setupset	endpoints	resourcesr.   	blueprintinit_app)	selfr.   rA   rB   rC   rD   rE   rF   rG   s	            r'   __init__zApi.__init__f   s      ++BC	!2(2*,&<#,l#?DHMM# r1   c                     	 |j                  | j                         || _        y# t        $ r | j	                  |       Y yw xY w)ai  Initialize this class with the given :class:`flask.Flask`
        application or :class:`flask.Blueprint` object.

        :param app: the Flask application or blueprint object
        :type app: flask.Flask
        :type app: flask.Blueprint

        Examples::

            api = Api()
            api.add_resource(...)
            api.init_app(app)

        N)record_deferred_blueprint_initrL   AttributeError	_init_app)rN   r.   s     r'   rM   zApi.init_app}   s?     	!JJt445
 !DN  	 NN3	 s   % AAc                 l    || j                   |ddj                  fd| j                  D              S )ai  This method is used to defer the construction of the final url in
        the case that the Api is created with a Blueprint.

        :param url_part: The part of the url the endpoint is registered with
        :param registration_prefix: The part of the url contributed by the
            blueprint.  Generally speaking, BlueprintSetupState.url_prefix
        )bar&    c              3   4   K   | ]  }|   s	|     y wr3    ).0keypartss     r'   	<genexpr>z$Api._complete_url.<locals>.<genexpr>   s     OcE#JuSzOs   

)rA   joinrF   )rN   url_partregistration_prefixr]   s      @r'   _complete_urlzApi._complete_url   s6     %

 wwOT-@-@OOOr1   c                    t        |      r || j                        }n| j                  r| j                  |z   }|j                  d| j                         ||j                  }| j
                  }d|v rt        |fi |j                  d      } | j                  j                  || j                  j                  d||fd|i| y)aw  Method used to patch BlueprintSetupState.add_url_rule for setup
        state instance corresponding to this Api instance.  Exists primarily
        to enable _complete_url's function.

        :param blueprint_setup: The BlueprintSetupState instance (self)
        :param rule: A string or callable that takes a string and returns a
            string(_complete_url) that is the url rule for the endpoint
            being registered
        :param endpoint: See BlueprintSetupState.add_url_rule
        :param view_func: See BlueprintSetupState.add_url_rule
        :param **options: See BlueprintSetupState.add_url_rule
        	subdomainNdefaults.)callable
url_prefix
setdefaultrd   __name__url_defaultsdictpopr.   add_url_rulerL   name)rH   ruleendpoint	view_funcoptionsre   s         r'   #_blueprint_setup_add_url_rule_patchz'Api._blueprint_setup_add_url_rule_patch   s     D>223D''"--4D;(A(AB ))H"// H@J(?@H(((/:S:S:X:XZb/c)2	R=E	RIP	Rr1   c                    || _         |j                  j                  dk7  r0|j                  |_        t	        t
        j                  |      |_        |j                  st        d      | j                  |j                         y)a  Synchronize prefix between blueprint/api and registration options, then
        perform initialization with setup_state.app :class:`flask.Flask` object.
        When a :class:`flask_restful.Api` object is initialized with a blueprint,
        this method is recorded on the blueprint to be run when the blueprint is later
        registered to a :class:`flask.Flask` object.  This method also monkeypatches
        BlueprintSetupState.add_url_rule with _blueprint_setup_add_url_rule_patch.

        :param setup_state: The setup state object passed to deferred functions
            during blueprint registration
        :type setup_state: flask.blueprints.BlueprintSetupState

        rt   z5flask-restful blueprints can only be registered once.N)rH   rn   rj   _original_add_url_ruler   r   rt   first_registration
ValueErrorrT   r.   )rN   setup_states     r'   rR   zApi._deferred_blueprint_init   sl      +##,,0UU1<1I1IK.'1#2Y2Y2=(?K$--TUU{'r1   c                 "   t        | j                  |j                        |_        t        | j                  |j                        |_        t	        | j
                        dkD  r-| j
                  D ]  \  }}} | j                  ||g|i |  yy)zPerform initialization actions with the given :class:`flask.Flask`
        object.

        :param app: The flask application object
        :type app: flask.Flask
        r   N)r   error_routerhandle_exceptionhandle_user_exceptionr"   rK   _register_view)rN   r.   resourcer@   r%   s        r'   rT   zApi._init_app   s      't'8'8#:N:NO$+D,=,=s?X?X$Y!t~~"*... D&$###CCDCFCD #r1   c                     | j                   rS|j                  | j                   j                        r-|j                  | j                   j                  dz   d      d   }ny|| j                  v S )zTests if an endpoint name (not path) belongs to this Api.  Takes
        in to account the Blueprint name part of the endpoint name.

        :param endpoint: The name of the endpoint being checked
        :return: bool
        rf      F)rL   
startswithro   splitrJ   )rN   rq   s     r'   owns_endpointzApi.owns_endpoint   sY     >>""4>>#6#67#>>$..*=*=*CQGK4>>))r1   c                 4   t        j                  t              }	 |j                          y# t        $ rJ}|j
                  d   }|j                  |d      \  }}| j                  |j                        cY d}~S d}~wt        $ r | j                  cY S  Y yxY w)a-   Determine if error should be handled with FR or default Flask

        The goal is to return Flask error handlers for non-FR-related routes,
        and FR errors (with the correct media type) for FR endpoints. This
        method currently handles 404 and 405 errors.

        :return: bool
        r   T)methodreturn_ruleN)
r   create_url_adapterr   matchr   valid_methodsr   rq   r   rD   )rN   adapterr&   valid_route_methodrp   _s         r'   _should_use_fr_error_handlerz Api._should_use_fr_error_handler   s     009	MMO 	5!"!3mm+=4mPGD!%%dmm44 	'&&&	s    , 	B?A:4B:BBc                     | j                         ryt        j                  sy| j                  t        j                  j                        S )zGEncapsulating the rules for whether the request was to a Flask endpointTF)r   r   url_ruler   rq   rN   s    r'   _has_fr_routezApi._has_fr_route  s<     ,,.!!'"2"2";";<<r1   c                 t    | j                         r	 | j                  |      S  ||      S # t        $ r Y w xY w)a  This function decides whether the error occured in a flask-restful
        endpoint or not. If it happened in a flask-restful endpoint, our
        handler will be dispatched. If it happened in an unrelated view, the
        app's original error handler will be dispatched.
        In the event that the error occurred in a flask-restful endpoint but
        the local handler can't resolve the situation, the router will fall
        back onto the original_handler as last resort.

        :param original_handler: the original Flask error handler for the app
        :type original_handler: function
        :param e: the exception raised while handling the request
        :type e: Exception

        )r   handle_error	Exception)rN   original_handlerr&   s      r'   r{   zApi.error_router  sG     ((++  ""  s   + 	77c                    t        j                  t        j                         |       t	        t        |       t               }t        |t              r]|j                  |j                         }|S |j                  }dt        |dt        |            i}|j                         j                  }nd}dt        |      i}d}|D ]  }|j                  |d        t        |d|      }|r5|dk\  r0t        j                          }	|	d   d}	t        j"                  |	       t%        |      j&                  }
|
| j(                  v r?| j(                  j+                  |
i       }|j+                  d	d      }|j-                  |       |d
k(  rN| j.                  Bt1        | j2                  j5                               }|r|d   nd}| j7                  ||||      }n| j7                  |||      }|dk(  r| j9                  |      }|S )zError handler for the API transforms a raised exception into a Flask
        response, with the appropriate HTTP status code and body.

        :param e: the raised Exception object
        :type e: Exception

        )	exceptionNmessagedescriptioni  )zContent-Lengthr#   r   statusi  r   
text/plain)fallback_mediatypei  )r   sendr   _get_current_objectr:   r   r4   r   responseget_responsecodegetattrr   headersrm   r5   r6   log_exceptiontyperj   rG   r*   updaterB   listr?   keysr
   unauthorized)rN   r&   r   respr   default_dataremove_headersheaderr#   r6   error_cls_namecustom_datasupported_mediatypesr   s                 r'   r   zApi.handle_error,  s    	"";#B#B#DPQR1+qA)a'zz% ~~'66D71m5H5NOL nn&..GD.t4L -$ 	&FKK%	& q&,/DCK||~H{"%%h/a))T[[(++//."=K??8S1DKK$3;4119
 $((<(<(A(A(C#D <P!5a!8Vb%%%7	 & D %%dD':D3;$$T*Dr1   c                       fdS )z:Return a method that returns a list of mediatypes
        c                 @    j                         j                  gz   S r3   )
mediatypesrB   )resource_clsrN   s    r'   <lambda>z'Api.mediatypes_method.<locals>.<lambda>y  s    DOO$59O9O8P$P r1   rZ   r   s   `r'   mediatypes_methodzApi.mediatypes_methodv  s     QPr1   c                     | j                   " | j                  | j                   |g|i | y| j                  j                  |||f       y)a  Adds a resource to the api.

        :param resource: the class name of your resource
        :type resource: :class:`Type[Resource]`

        :param urls: one or more url routes to match for the resource, standard
                     flask routing rules apply.  Any url variables will be
                     passed to the resource method as args.
        :type urls: str

        :param endpoint: endpoint name (defaults to :meth:`Resource.__name__.lower`
            Can be used to reference this route in :class:`fields.Url` fields
        :type endpoint: str

        :param resource_class_args: args to be forwarded to the constructor of
            the resource.
        :type resource_class_args: tuple

        :param resource_class_kwargs: kwargs to be forwarded to the constructor
            of the resource.
        :type resource_class_kwargs: dict

        Additional keyword arguments not specified above will be passed as-is
        to :meth:`flask.Flask.add_url_rule`.

        Examples::

            api.add_resource(HelloWorld, '/', '/hello')
            api.add_resource(Foo, '/foo', endpoint="foo")
            api.add_resource(FooSpecial, '/special/foo', endpoint="foo")

        N)r.   r~   rK   append)rN   r   r@   r%   s       r'   add_resourcezApi.add_resource{  sH    B 88D(DTDVDNN!!8T6":;r1   c                       fd}|S )a  Wraps a :class:`~flask_restful.Resource` class, adding it to the
        api. Parameters are the same as :meth:`~flask_restful.Api.add_resource`.

        Example::

            app = Flask(__name__)
            api = restful.Api(app)

            @api.resource('/foo')
            class Foo(Resource):
                def get(self):
                    return 'Hello, World!'

        c                 4     j                   | gi  | S r3   )r   )clsr%   rN   r@   s    r'   	decoratorzApi.resource.<locals>.decorator  s"    Dc3D3F3Jr1   rZ   )rN   r@   r%   r   s   ``` r'   r   zApi.resource  s    	 r1   c                 $   |j                  dd       xs |j                  j                         }| j                  j	                  |       |j                  dd      }|j                  di       }|t        |di       v r=|j                  |   j                  d   }||k7  rt        d|d|j                  d	      | j                         |_
        ||_        | j                   |j                  |g|i |      }	| j                  D ]
  }
 |
|	      }	 |D ]x  }| j                  rC| j                   r  | j                   j"                  |fd
|	i| ;t%        | j&                  |      }n| j'                  |d      } |j"                  |fd
|	i| z y )Nrq   resource_class_argsrZ   resource_class_kwargsview_functions
view_classzThis endpoint (z) is already set to the class rf   rr   rX   )rm   rj   lowerrJ   addr   r   __dict__rx   r   r   rq   outputas_viewrC   rL   rH   rn   r   rb   )rN   r.   r   r@   r%   rq   r   r   previous_view_classresource_funcr   urlrp   s                r'   r~   zApi._register_view  s   ::j$/L83D3D3J3J3L8$$jj)>C &

+BB G ws$4b99"%"4"4X">"G"G"U #h. Yacvcc  "A  B  B"446$$4H$4$4X %%@S %%#%% &  	5I%m4M	5  	FC~~'' 6D((55c]]]V\] #4#5#5s;D ))#r2CTE]EfE)	Fr1   c                 2     t               fd       }|S )zWraps a resource (as a flask view function), for cases where the
        resource does not directly return a response object

        :param resource: The resource as a flask view function
        c                  ~     | i |}t        |t              r|S t        |      \  }}}j                  |||      S )N)r   )r4   ResponseBaser   r
   )argsr%   r   r#   r   r   r   rN   s         r'   wrapperzApi.output.<locals>.wrapper  sI    T,V,D$-"(,D$%%dD'%BBr1   r   )rN   r   r   s   `` r'   r   z
Api.output  s$     
x	C 
	C r1   c                     |j                   }| j                  r&dj                  | j                  j                  |      }t	        |fi |S )zQGenerates a URL to the given resource.

        Works like :func:`flask.url_for`.z{0}.{1})rq   rL   formatro   r   )rN   r   valuesrq   s       r'   r   zApi.url_for  sB     $$>> ''(;(;XFHx*6**r1   c                    |j                  dd      xs | j                  }t        j                  j	                  | j
                  |      }|
t               || j
                  v r* | j
                  |   |g|i |}||j                  d<   |S |dk(  r)t        t        |      g|i |}d|j                  d<   |S t               )a  Looks up the representation transformer for the requested media
        type, invoking the transformer to create a response object. This
        defaults to default_mediatype if no transformer is found for the
        requested mediatype. If default_mediatype is None, a 406 Not
        Acceptable response will be sent as per RFC 2616 section 14.1

        :param data: Python object containing response data to be transformed
        r   NdefaultContent-Typer   )rm   rB   r   accept_mimetypes
best_matchr?   r   r   original_flask_make_responsestrr   )rN   r#   r   r%   rB   	mediatyper   s          r'   r
   zApi.make_response  s     #JJ';TB\dF\F\,,77  % 8 
	 /!,,,24''	24I$I&ID+4DLL(K,&/D	KDKFKD+7DLL(K%''r1   c                     t        t        j                  t        j                  d      d      D cg c]  \  }}|	 c}}S c c}}w )z@Returns a list of requested mediatypes sent in the Accept headerr   T)r\   reverse)sortedr   r   operator
itemgetter)rN   hqs      r'   r   zApi.mediatypes  sD    $W%=%=)1)<)<Q)?O Pda P 	P Ps   Ac                       fd}|S )a  Allows additional representation transformers to be declared for the
        api. Transformers are functions that must be decorated with this
        method, passing the mediatype the transformer represents. Three
        arguments are passed to the transformer:

        * The data to be represented in the response body
        * The http status code
        * A dictionary of headers

        The transformer should convert the data appropriately for the mediatype
        and return a Flask response object.

        Ex::

            @api.representation('application/xml')
            def xml(data, code, headers):
                resp = make_response(convert_data_to_xml(data), code)
                resp.headers.extend(headers)
                return resp
        c                 &    | j                   <   | S r3   )r?   )funcr   rN   s    r'   r   z#Api.representation.<locals>.wrapper.  s    .2D  +Kr1   rZ   )rN   r   r   s   `` r'   representationzApi.representation  s    *	 r1   c                     | j                   rAt        j                  j                  dd      }dj	                  d|      }||j
                  d<   |S )z4 Given a response, change it to ask for credentials HTTP_BASIC_AUTH_REALMzflask-restfulz{0} realm="{1}"BasiczWWW-Authenticate)rE   r   r)   r*   r   r   )rN   r   realm	challenges       r'   r   zApi.unauthorized3  sN     &&&&**+BOTE,33GUCI3<H/0r1   )NrX   r;   NFFbaeN)NN)rj   
__module____qualname____doc__rO   rM   rb   staticmethodrt   rR   rT   r   r   r   r{   r   r   r   r   r~   r   r   r
   r   r   r   rZ   r1   r'   r   r   C   s     D )+BF>C.2.!0P R R6(.D*0=#,HTQ
$<L(*FX+(6P
4r1   r   c                       e Zd ZdZdZg Zd Zy)r   a  
    Represents an abstract RESTful resource. Concrete resources should
    extend from this class and expose methods for each supported HTTP
    method. If a resource is invoked with an unsupported HTTP method,
    the API will return a response with status 405 Method Not Allowed.
    Otherwise the appropriate method is called and passed all arguments
    from the url rule used when adding the resource to an Api instance. See
    :meth:`~flask_restful.Api.add_resource` for details.
    Nc                    t        | t        j                  j                         d       }| t        j                  dk(  rt        | dd       }|J dt        j                  z         t	        | j
                  t              r9| j
                  j                  t        j                  j                         g       }n| j
                  }|D ]
  } ||      }  ||i |}t	        |t              r|S | j                  xs
 t               }t        j                  j                  |d       }||v r-t        |      \  }	}
} ||   |	|
|      }||j                  d<   |S |S )NHEADr*   zUnimplemented method %rr   r   )r   r   r   r   r4   method_decoratorsr   r*   r   r?   r   r   r   r   r   )rN   r   r%   methrC   r   r   r?   r   r#   r   r   s               r'   dispatch_requestzResource.dispatch_requestK  sE    tW^^113T:<GNNf44-DK!:W^^!KKd,,g6//33GNN4H4H4JBOJ//J# 	#IT?D	# T$V$dL)K..?+- ,,77QU7V	'"(,D$-?9-dD'BD+4DLL(Kr1   )rj   r   r   r   r?   r   r   rZ   r1   r'   r   r   >  s     O r1   r   c           
      L    d t         t        t        f      rB|r&t        | D cg c]  }t	        ||       c}fg      S  D cg c]  }t	        ||       c}S  fd|j                         D        }|rt        |t        |      fg      S t        |      S c c}w c c}w )a  Takes raw data (in the form of a dict, list, object) and a dict of
    fields to output and filters the data based on those fields.

    :param data: the actual object(s) from which the fields are taken from
    :param fields: a dict of whose keys will make up the final serialized
                   response output
    :param envelope: optional key that will be used to envelop the serialized
                     response


    >>> from flask_restful import fields, marshal
    >>> data = { 'a': 100, 'b': 'foo' }
    >>> mfields = { 'a': fields.Raw }

    >>> marshal(data, mfields)
    OrderedDict([('a', 100)])

    >>> marshal(data, mfields, envelope='data')
    OrderedDict([('data', OrderedDict([('a', 100)]))])

    c                 4    t        | t              r |        S | S r3   )r4   r   )r   s    r'   makezmarshal.<locals>.make  s    c4 5L
r1   c              3      K   | ]=  \  }}|t        |t              rt        |      n |      j                  |      f ? y wr3   )r4   rl   r   r   )r[   kvr#   r   s      r'   r^   zmarshal.<locals>.<genexpr>  sF      )A Z4%8q!7>>!T*, )s   AA)r4   r   tupler   r   items)r#   fieldsenvelopedr  r   s   `    @r'   r   r   n  s    .
 $u& hT(JF);(JKLM 	E>B!C'!V"4!C	E))E =E;;u#5678\+V[J\\ )K!Cs   B
B!c                       e Zd ZdZddZd Zy)r   a1  A decorator that apply marshalling to the return values of your methods.

    >>> from flask_restful import fields, marshal_with
    >>> mfields = { 'a': fields.Raw }
    >>> @marshal_with(mfields)
    ... def get():
    ...     return { 'a': 100, 'b': 'foo' }
    ...
    ...
    >>> get()
    OrderedDict([('a', 100)])

    >>> @marshal_with(mfields, envelope='data')
    ... def get():
    ...     return { 'a': 100, 'b': 'foo' }
    ...
    ...
    >>> get()
    OrderedDict([('data', OrderedDict([('a', 100)]))])

    see :meth:`flask_restful.marshal`
    Nc                      || _         || _        y)z
        :param fields: a dict of whose keys will make up the final
                       serialized response output
        :param envelope: optional key that will be used to envelop the serialized
                         response
        N)r  r  )rN   r  r  s      r'   rO   zmarshal_with.__init__  s      r1   c                 2     t               fd       }|S )Nc                       | i |}t        |t              r3t        |      \  }}}t        |j                  j
                        ||fS t        |j                  j
                        S r3   )r4   r   r   r   r  r  r   r%   r   r#   r   r   frN   s         r'   r   z&marshal_with.__call__.<locals>.wrapper  sa    d%f%D$&&,Tl#dGtT[[$--@$OOtT[[$--@@r1   r   rN   r
  r   s   `` r'   __call__zmarshal_with.__call__  s"    	q	A 
	A r1   r3   rj   r   r   r   rO   r  rZ   r1   r'   r   r     s    ,!	r1   r   c                       e Zd ZdZd Zd Zy)r   aT  
    A decorator that formats the return values of your methods with a single field.

    >>> from flask_restful import marshal_with_field, fields
    >>> @marshal_with_field(fields.List(fields.Integer))
    ... def get():
    ...     return ['1', 2, 3.0]
    ...
    >>> get()
    [1, 2, 3]

    see :meth:`flask_restful.marshal_with`
    c                 L    t        |t              r |       | _        y|| _        y)zP
        :param field: a single field with which to marshal the output.
        N)r4   r   field)rN   r  s     r'   rO   zmarshal_with_field.__init__  s     eT"DJDJr1   c                 2     t               fd       }|S )Nc                       | i |}t        |t              r-t        |      \  }}}j                  j	                  |      ||fS j                  j	                  |      S r3   )r4   r   r   r  r   r	  s         r'   r   z,marshal_with_field.__call__.<locals>.wrapper  s]    d%f%D$&&,Tl#dGzz((.g==::$$T**r1   r   r  s   `` r'   r  zmarshal_with_field.__call__  s     	q	+ 
	+ r1   Nr  rZ   r1   r'   r   r     s    
r1   r   r3   )5
__future__r   	functoolsr   r   flaskr   r   r   r	   r!   r
   r   flask.viewsr   flask.signalsr   werkzeug.datastructuresr   werkzeug.exceptionsr   r   r   r   r   werkzeug.wrappersr   r   flask_restful.utilsr   r   r   "flask_restful.representations.jsonr   r5   typesr   r   collections.abcr   ImportErrorcollectionsr+   __all__r0   r:   r>   objectr   r   r   r   r   rZ   r1   r'   <module>r#     s    & $ / / / ? " / + m m 6 H H : 
  $' / 
W
  /<= x& xv-z -`#]L*6 *Z! !_  $#$s   *B3 3C C