ó
Xé?_c           @   s}   d  d l  Z  d  d l m Z m Z m Z m Z d „  Z e d ƒ e d ƒ g e e e d „ Z	 d „  Z
 d e e
 d „ Z d S(	   iÿÿÿÿN(   t
   basestringt   ntout   json_encodet   json_decodec         C   sŽ   |  j  j t d ƒ t d ƒ ƒ s3 t j d ƒ ‚ n  |  j j ƒ  } y" t | j d ƒ ƒ t j	 j
 _ Wn# t k
 r‰ t j d d ƒ ‚ n Xd S(   s-   Read application/json data into request.json.s   Content-Lengtht    i›  s   utf-8i  s   Invalid JSON documentN(   t   headerst   getR   t   cherrypyt	   HTTPErrort   fpt   readR   t   decodet   servingt   requestt   jsont
   ValueError(   t   entityt   body(    (    s}   /local/mnt/workspace/CRMBuilds/Saipan.LA.2.0-00145-STD.PROD-1_20200821_083004/b/common/sectools/ext/cherrypy/lib/jsontools.pyt   json_processor   s    !"s   application/jsons   text/javascriptc         C   sÖ   t  j j } t |  t ƒ r' |  g }  n  | r” | r\ t  j d t | j j j	 ƒ  ƒ d ƒ n  | j j j
 ƒ  t  j d d d j |  ƒ ƒ | j _ n  x; |  D]3 } | r¾ t  j d | d ƒ n  | | j j | <q› Wd S(   s§  Add a processor to parse JSON request entities:
    The default processor places the parsed data into request.json.

    Incoming request entities which match the given content_type(s) will
    be deserialized from JSON to the Python equivalent, and the result
    stored at cherrypy.request.json. The 'content_type' argument may
    be a Content-Type string or a list of allowable Content-Type strings.

    If the 'force' argument is True (the default), then entities of other
    content types will not be allowed; "415 Unsupported Media Type" is
    raised instead.

    Supply your own processor to use a custom decoder, or to handle the parsed
    data differently.  The processor can be configured via
    tools.json_in.processor or via the decorator method.

    Note that the deserializer requires the client send a Content-Length
    request header, or it will raise "411 Length Required". If for any
    other reason the request entity cannot be deserialized from JSON,
    it will raise "400 Bad Request: Invalid JSON document".

    You must be using Python 2.6 or greater, or have the 'simplejson'
    package importable; otherwise, ValueError is raised during processing.
    s   Removing body processors %ss   TOOLS.JSON_INiŸ  s%   Expected an entity of content type %ss   , s   Adding body processor for %sN(   R   R   R   t
   isinstanceR    t   logt   reprR   t
   processorst   keyst   clearR   t   joint   default_proc(   t   content_typet   forcet   debugt	   processorR   t   ct(    (    s}   /local/mnt/workspace/CRMBuilds/Saipan.LA.2.0-00145-STD.PROD-1_20200821_083004/b/common/sectools/ext/cherrypy/lib/jsontools.pyt   json_in   s    	 c          O   s"   t  j j j |  | Ž  } t | ƒ S(   N(   R   R   R   t   _json_inner_handlerR   (   t   argst   kwargst   value(    (    s}   /local/mnt/workspace/CRMBuilds/Saipan.LA.2.0-00145-STD.PROD-1_20200821_083004/b/common/sectools/ext/cherrypy/lib/jsontools.pyt   json_handler>   s    c         C   s—   t  j j } | j d k r d S| r? t  j d | j d ƒ n  | j | _ | | _ |  d k	 r“ | r} t  j d |  d ƒ n  |  t  j j j d <n  d S(   sÜ  Wrap request.handler to serialize its output to JSON. Sets Content-Type.

    If the given content_type is None, the Content-Type response header
    is not set.

    Provide your own handler to use a custom encoder.  For example
    cherrypy.config['tools.json_out.handler'] = <function>, or
    @json_out(handler=function).

    You must be using Python 2.6 or greater, or have the 'simplejson'
    package importable; otherwise, ValueError is raised during processing.
    Ns   Replacing %s with JSON handlers   TOOLS.JSON_OUTs   Setting Content-Type to %ss   Content-Type(	   R   R   R   t   handlert   NoneR   R!   t   responseR   (   R   R   R&   R   (    (    s}   /local/mnt/workspace/CRMBuilds/Saipan.LA.2.0-00145-STD.PROD-1_20200821_083004/b/common/sectools/ext/cherrypy/lib/jsontools.pyt   json_outC   s    
		(   R   t   cherrypy._cpcompatR    R   R   R   R   t   Truet   FalseR    R%   R)   (    (    (    s}   /local/mnt/workspace/CRMBuilds/Saipan.LA.2.0-00145-STD.PROD-1_20200821_083004/b/common/sectools/ext/cherrypy/lib/jsontools.pyt   <module>   s   "	,	