B
    `-                 @   sR  d Z ddl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 dd	lmZ d
d Ze
eG dd deeZeZG dd deZG dd deZG dd deZG dd deZG dd deZG dd deZG dd deZG dd deZG dd deZG d d! d!eZG d"d# d#eZG d$d% d%eZ G d&d' d'eZ!G d(d) d)eZ"G d*d+ d+eZ#G d,d- d-eZ$G d.d/ d/eZ%G d0d1 d1eZ&G d2d3 d3eZ'G d4d5 d5eZ(G d6d7 d7e(Z)G d8d9 d9e(Z*G d:d; d;e(Z+G d<d= d=e(Z,G d>d? d?e(Z-G d@dA dAe(Z.G dBdC dCe(Z/G dDdE dEe(Z0G dFdG dGe(Z1G dHdI dIe(Z2G dJdK dKe(Z3G dLdM dMe(Z4G dNdO dOe(Z5G dPdQ dQe(Z6G dRdS dSe(Z7G dTdU dUe(Z8G dVdW dWe(Z9G dXdY dYe(Z:G dZd[ d[e(Z;G d\d] d]e(Z<G d^d_ d_e(Z=G d`da dae(Z>G dbdc dce(Z?G ddde dee(Z@G dfdg dgeZAG dhdi dieAZBG djdk dkeAZCG dldm dmeAZDG dndo doeAZEG dpdq dqeAZFG drds dseAZGG dtdu dueAZHdvdw ZIdxdy ZJi ZKdZLxheMeN O D ]V\ZPZQeReQeSreTeQereQe(eAhkrePUdzseVeQd{dZLeLreQeKeL< qW [P[Q[LdS )|a  
HTTP Exceptions
---------------

This module contains Pyramid HTTP exception classes.  Each class relates to a
single HTTP status code.  Each class is a subclass of the
:class:`~HTTPException`.  Each exception class is also a :term:`response`
object.

Each exception class has a status code according to :rfc:`2068` or :rfc:`7538`:
codes with 100-300 are not really errors; 400s are client errors,
and 500s are server errors.

Exception
  HTTPException
    HTTPSuccessful
      * 200 - HTTPOk
      * 201 - HTTPCreated
      * 202 - HTTPAccepted
      * 203 - HTTPNonAuthoritativeInformation
      * 204 - HTTPNoContent
      * 205 - HTTPResetContent
      * 206 - HTTPPartialContent
    HTTPRedirection
      * 300 - HTTPMultipleChoices
      * 301 - HTTPMovedPermanently
      * 302 - HTTPFound
      * 303 - HTTPSeeOther
      * 304 - HTTPNotModified
      * 305 - HTTPUseProxy
      * 307 - HTTPTemporaryRedirect
      * 308 - HTTPPermanentRedirect
    HTTPError
      HTTPClientError
        * 400 - HTTPBadRequest
        * 401 - HTTPUnauthorized
        * 402 - HTTPPaymentRequired
        * 403 - HTTPForbidden
        * 404 - HTTPNotFound
        * 405 - HTTPMethodNotAllowed
        * 406 - HTTPNotAcceptable
        * 407 - HTTPProxyAuthenticationRequired
        * 408 - HTTPRequestTimeout
        * 409 - HTTPConflict
        * 410 - HTTPGone
        * 411 - HTTPLengthRequired
        * 412 - HTTPPreconditionFailed
        * 413 - HTTPRequestEntityTooLarge
        * 414 - HTTPRequestURITooLong
        * 415 - HTTPUnsupportedMediaType
        * 416 - HTTPRequestRangeNotSatisfiable
        * 417 - HTTPExpectationFailed
        * 422 - HTTPUnprocessableEntity
        * 423 - HTTPLocked
        * 424 - HTTPFailedDependency
        * 428 - HTTPPreconditionRequired
        * 429 - HTTPTooManyRequests
        * 431 - HTTPRequestHeaderFieldsTooLarge
      HTTPServerError
        * 500 - HTTPInternalServerError
        * 501 - HTTPNotImplemented
        * 502 - HTTPBadGateway
        * 503 - HTTPServiceUnavailable
        * 504 - HTTPGatewayTimeout
        * 505 - HTTPVersionNotSupported
        * 507 - HTTPInsufficientStorage

HTTP exceptions are also :term:`response` objects, thus they accept most of
the same parameters that can be passed to a regular
:class:`~pyramid.response.Response`. Each HTTP exception also has the
following attributes:

   ``code``
       the HTTP status code for the exception

   ``title``
       remainder of the status line (stuff after the code)

   ``explanation``
       a plain-text explanation of the error message that is
       not subject to environment or header substitutions;
       it is accessible in the template via ${explanation}

   ``detail``
       a plain-text message customization that is not subject
       to environment or header substitutions; accessible in
       the template via ${detail}

   ``body_template``
       a ``String.template``-format content fragment used for environment
       and header substitution; the default template includes both
       the explanation and further detail provided in the
       message.

Each HTTP exception accepts the following parameters, any others will
be forwarded to its :class:`~pyramid.response.Response` superclass:

   ``detail``
     a plain-text override of the default ``detail``

   ``headers``
     a list of (k,v) header pairs, or a dict, to be added to the
     response; use the content_type='application/json' kwarg and other
     similar kwargs to to change properties of the response supported by the
     :class:`pyramid.response.Response` superclass

   ``comment``
     a plain-text additional information which is
     usually stripped/hidden for end-users

   ``body_template``
     a ``string.Template`` object containing a content fragment in HTML
     that frames the explanation and further detail

   ``body``
     a string that will override the ``body_template`` and be used as the
     body of the response.

Substitution of response headers into template values is always performed.
Substitution of WSGI environment values is performed if a ``request`` is
passed to the exception's constructor.

The subclasses of :class:`~_HTTPMove`
(:class:`~HTTPMultipleChoices`, :class:`~HTTPMovedPermanently`,
:class:`~HTTPFound`, :class:`~HTTPSeeOther`, :class:`~HTTPUseProxy`,
:class:`~HTTPTemporaryRedirect`, and :class: `~HTTPPermanentRedirect) are
redirections that require a ``Location`` field. Reflecting this, these
subclasses have one additional keyword argument: ``location``,
which indicates the location to which to redirect.
    N)Template)html_escape)create_accept_header)implementer)IExceptionResponse)Response)text_c             C   s8   | d krdS t | ts4t | tr,t| d} nt| } | S )N zutf-8)
isinstancestrbytesr   )value r   ^/home/kop/projects/devel/pgwui/test_venv/lib/python3.7/site-packages/pyramid/httpexceptions.py
_no_escape   s    

r   c               @   sn   e Zd ZdZdZdZedZedZedZ	dZ
dd	d
Zdd Zdd Zdd Zedd ZeZdd ZdS )HTTPExceptioni  zUnknown Errorr	   z3${explanation}${br}${br}
${detail}
${html_comment}
z${status}

${body}zj<html>
 <head>
  <title>${status}</title>
 </head>
 <body>
  <h1>${status}</h1>
  ${body}
 </body>
</html>FNc             K   s   d| j | jf }tj| fd|i| t| | | | _| _|rN| j| || _	|d k	rl|| _
t|| _|d k	rz|| _| jr| `| `d S )Nz%s %sstatus)codetitler   __init__	Exceptiondetailmessageheadersextendcommentbody_templater   body_template_obj_json_formatter
empty_bodycontent_typecontent_length)selfr   r   r   r   Zjson_formatterkwr   r   r   r   r      s    	
zHTTPException.__init__c             C   s   | j rt| j S | jS )N)r   r   explanation)r"   r   r   r   __str__   s    zHTTPException.__str__c             C   s   ||| j dS )N)r   r   r   )r   )r"   r   bodyr   environr   r   r   r      s    zHTTPException._json_formatterc                s  | j s| jsd}| jpd} dd}t|}|ddg}dd |D dg }|d }|dkrd| _t}| j}	d	}
|rd
|| }nd|dkrd| _d | _	t
}d}
|r||}G  fddd}|| }	n d| _t
}| j}	d}
|r||}|
|| j|| jpd|||d}| j}tj|k	rx<  D ]0\}}|dsRd|krRq0||||< q0W x(| j D ]\}}|||| < qpW ||}|	j| j|d}t|tr|| j	r| j	nd}|g| _|| _d S )Nr	   ZHTTP_ACCEPTz	text/htmlzapplication/jsonc             S   s   g | ]}|d  qS )r   r   ).0Zofferr   r   r   
<listcomp>  s    z)HTTPException.prepare.<locals>.<listcomp>z
text/plainr   z<br/>z<!-- %s -->
c                   s    e Zd Zdd Z fddZdS )z/HTTPException.prepare.<locals>.JsonPageTemplatec             S   s
   || _ d S )N)excobj)r"   r+   r   r   r   r     s    z8HTTPException.prepare.<locals>.JsonPageTemplate.__init__c                s"   | j j||| j j d}t|S )N)r   r&   r   r'   )r+   r   r   jsondumps)r"   r   r&   Zjsonbody)r'   r   r   
substitute  s    z:HTTPException.prepare.<locals>.JsonPageTemplate.substituteN)__name__
__module____qualname__r   r.   r   )r'   r   r   JsonPageTemplate  s   r2   )brr$   r   r   html_commentzwsgi..)r   r&   zUTF-8)Zhas_bodyr   r   getr   Zacceptable_offersr    _html_escapehtml_template_objcharsetr   plain_template_objr$   r   r   r   items
startswithr   lowerr.   r   r
   r   encodeZapp_iterr&   )r"   r'   r4   r   Zaccept_valueacceptZ
acceptablematchescapeZpage_templater3   r2   argsZ	body_tmplkvr&   pager   )r'   r   prepare   sd    



zHTTPException.preparec             C   s   | S )Nr   )r"   r   r   r   wsgi_responseH  s    zHTTPException.wsgi_responsec             C   s   |  | t| ||S )N)rF   r   __call__)r"   r'   Zstart_responser   r   r   rH   O  s    
zHTTPException.__call__)NNNNN)r/   r0   r1   r   r   r$   r   r   r:   r8   r   r   r%   r   rF   propertyrG   	exceptionrH   r   r   r   r   r      s*   !
    
Lr   c               @   s   e Zd ZdZdS )	HTTPErrorz
    base class for exceptions with status codes in the 400s and 500s

    This is an exception which indicates that an error has occurred,
    and that any work in progress should not be committed.
    N)r/   r0   r1   __doc__r   r   r   r   rK   ^  s   rK   c               @   s   e Zd ZdZdS )HTTPRedirectiona0  
    base class for exceptions with status codes in the 300s (redirections)

    This is an abstract base class for 3xx redirection.  It indicates
    that further action needs to be taken by the user agent in order
    to fulfill the request.  It does not necessarily signal an error
    condition.
    N)r/   r0   r1   rL   r   r   r   r   rM   g  s   rM   c               @   s   e Zd ZdZdS )HTTPSuccessfulz\
    Base class for exceptions with status codes in the 200s (successful
    responses)
    N)r/   r0   r1   rL   r   r   r   r   rN   r  s   rN   c               @   s   e Zd ZdZdZdZdS )HTTPOkzw
    subclass of :class:`~HTTPSuccessful`

    Indicates that the request has succeeded.

    code: 200, title: OK
       OKN)r/   r0   r1   rL   r   r   r   r   r   r   rO   ~  s   rO   c               @   s   e Zd ZdZdZdZdS )HTTPCreatedz
    subclass of :class:`~HTTPSuccessful`

    This indicates that request has been fulfilled and resulted in a new
    resource being created.

    code: 201, title: Created
       CreatedN)r/   r0   r1   rL   r   r   r   r   r   r   rR     s   rR   c               @   s   e Zd ZdZdZdZdZdS )HTTPAcceptedz
    subclass of :class:`~HTTPSuccessful`

    This indicates that the request has been accepted for processing, but the
    processing has not been completed.

    code: 202, title: Accepted
       Acceptedz'The request is accepted for processing.N)r/   r0   r1   rL   r   r   r$   r   r   r   r   rU     s   rU   c               @   s   e Zd ZdZdZdZdS )HTTPNonAuthoritativeInformationa)  
    subclass of :class:`~HTTPSuccessful`

    This indicates that the returned metainformation in the entity-header is
    not the definitive set as available from the origin server, but is
    gathered from a local or a third-party copy.

    code: 203, title: Non-Authoritative Information
       zNon-Authoritative InformationN)r/   r0   r1   rL   r   r   r   r   r   r   rX     s   	rX   c               @   s   e Zd ZdZdZdZdZdS )HTTPNoContentz
    subclass of :class:`~HTTPSuccessful`

    This indicates that the server has fulfilled the request but does
    not need to return an entity-body, and might want to return updated
    metainformation.

    code: 204, title: No Content
       z
No ContentTN)r/   r0   r1   rL   r   r   r   r   r   r   r   rZ     s   	rZ   c               @   s   e Zd ZdZdZdZdZdS )HTTPResetContentz
    subclass of :class:`~HTTPSuccessful`

    This indicates that the server has fulfilled the request and
    the user agent SHOULD reset the document view which caused the
    request to be sent.

    code: 205, title: Reset Content
       zReset ContentTN)r/   r0   r1   rL   r   r   r   r   r   r   r   r\     s   	r\   c               @   s   e Zd ZdZdZdZdS )HTTPPartialContentz
    subclass of :class:`~HTTPSuccessful`

    This indicates that the server has fulfilled the partial GET
    request for the resource.

    code: 206, title: Partial Content
       zPartial ContentN)r/   r0   r1   rL   r   r   r   r   r   r   r^     s   r^   c                   s.   e Zd ZdZdZedZd fdd	Z  ZS )		_HTTPMovea  
    redirections which require a Location field

    Since a 'Location' header is a required attribute of 301, 302, 303,
    305 and 307 (but not 304), this base class provides the mechanics to
    make this easy.

    You must provide a ``location`` keyword argument.
    zThe resource has been moved toz]${explanation} ${location}; you should be redirected automatically.
${detail}
${html_comment}r	   Nc                s2   |d krt dt jf |||||d| d S )Nz.HTTP redirects need a location to redirect to.)r   r   r   r   location)
ValueErrorsuperr   )r"   ra   r   r   r   r   r#   )	__class__r   r   r     s    	z_HTTPMove.__init__)r	   NNNN)	r/   r0   r1   rL   r$   r   r   r   __classcell__r   r   )rd   r   r`     s   	    r`   c               @   s   e Zd ZdZdZdZdS )HTTPMultipleChoicesa  
    subclass of :class:`~_HTTPMove`

    This indicates that the requested resource corresponds to any one
    of a set of representations, each with its own specific location,
    and agent-driven negotiation information is being provided so that
    the user can select a preferred representation and redirect its
    request to that location.

    code: 300, title: Multiple Choices
    i,  zMultiple ChoicesN)r/   r0   r1   rL   r   r   r   r   r   r   rf   !  s   rf   c               @   s   e Zd ZdZdZdZdS )HTTPMovedPermanentlya   
    subclass of :class:`~_HTTPMove`

    This indicates that the requested resource has been assigned a new
    permanent URI and any future references to this resource SHOULD use
    one of the returned URIs.

    code: 301, title: Moved Permanently
    i-  zMoved PermanentlyN)r/   r0   r1   rL   r   r   r   r   r   r   rg   2  s   	rg   c               @   s   e Zd ZdZdZdZdZdS )	HTTPFoundz
    subclass of :class:`~_HTTPMove`

    This indicates that the requested resource resides temporarily under
    a different URI.

    code: 302, title: Found
    i.  FoundzThe resource was found atN)r/   r0   r1   rL   r   r   r$   r   r   r   r   rh   A  s   rh   c               @   s   e Zd ZdZdZdZdS )HTTPSeeOtherz
    subclass of :class:`~_HTTPMove`

    This indicates that the response to the request can be found under
    a different URI and SHOULD be retrieved using a GET method on that
    resource.

    code: 303, title: See Other
    i/  z	See OtherN)r/   r0   r1   rL   r   r   r   r   r   r   rj   R  s   	rj   c               @   s   e Zd ZdZdZdZdZdS )HTTPNotModifieda  
    subclass of :class:`~HTTPRedirection`

    This indicates that if the client has performed a conditional GET
    request and access is allowed, but the document has not been
    modified, the server SHOULD respond with this status code.

    code: 304, title: Not Modified
    i0  zNot ModifiedTN)r/   r0   r1   rL   r   r   r   r   r   r   r   rk   a  s   	rk   c               @   s   e Zd ZdZdZdZdZdS )HTTPUseProxyz
    subclass of :class:`~_HTTPMove`

    This indicates that the requested resource MUST be accessed through
    the proxy given by the Location field.

    code: 305, title: Use Proxy
    i1  z	Use Proxyz8The resource must be accessed through a proxy located atN)r/   r0   r1   rL   r   r   r$   r   r   r   r   rl   r  s   rl   c               @   s   e Zd ZdZdZdZdS )HTTPTemporaryRedirectz
    subclass of :class:`~_HTTPMove`

    This indicates that the requested resource resides temporarily
    under a different URI.

    code: 307, title: Temporary Redirect
    i3  zTemporary RedirectN)r/   r0   r1   rL   r   r   r   r   r   r   rm     s   rm   c               @   s   e Zd ZdZdZdZdS )HTTPPermanentRedirectz
    subclass of :class:`~_HTTPMove`

    This indicates that the requested resource resides permanently
    under a different URI and that the request method must not be
    changed.

    code: 308, title: Permanent Redirect
    i4  zPermanent RedirectN)r/   r0   r1   rL   r   r   r   r   r   r   rn     s   	rn   c               @   s   e Zd ZdZdZdZdS )HTTPClientErrora7  
    base class for the 400s, where the client is in error

    This is an error condition in which the client is presumed to be
    in-error.  This is an expected problem, and thus is not considered
    a bug.  A server-side traceback is not warranted.  Unless specialized,
    this is a '400 Bad Request'
    i  zBad RequestN)r/   r0   r1   rL   r   r   r   r   r   r   ro     s   ro   c               @   s   e Zd ZdZdZdS )HTTPBadRequestz
    subclass of :class:`~HTTPClientError`

    This indicates that the body or headers failed validity checks,
    preventing the server from being able to continue processing.

    code: 400, title: Bad Request
    zaThe server could not comply with the request since it is either malformed or otherwise incorrect.N)r/   r0   r1   rL   r$   r   r   r   r   rp     s   rp   c               @   s   e Zd ZdZdZdZdZdS )HTTPUnauthorizedz
    subclass of :class:`~HTTPClientError`

    This indicates that the request requires user authentication.

    code: 401, title: Unauthorized
    i  UnauthorizedzThis server could not verify that you are authorized to access the document you requested.  Either you supplied the wrong credentials (e.g., bad password), or your browser does not understand how to supply the credentials required.N)r/   r0   r1   rL   r   r   r$   r   r   r   r   rq     s   rq   c               @   s   e Zd ZdZdZdZdZdS )HTTPPaymentRequiredzW
    subclass of :class:`~HTTPClientError`

    code: 402, title: Payment Required
    i  zPayment Requiredz(Access was denied for financial reasons.N)r/   r0   r1   rL   r   r   r$   r   r   r   r   rs     s   rs   c               @   s&   e Zd ZdZdZdZdZdddZdS )	HTTPForbiddenaT  
    subclass of :class:`~HTTPClientError`

    This indicates that the server understood the request, but is
    refusing to fulfill it.

    code: 403, title: Forbidden

    Raise this exception within :term:`view` code to immediately return the
    :term:`forbidden view` to the invoking user.  Usually this is a basic
    ``403`` page, but the forbidden view can be customized as necessary.  See
    :ref:`changing_the_forbidden_view`.  A ``Forbidden`` exception will be
    the ``context`` of a :term:`Forbidden View`.

    This exception's constructor treats two arguments specially.  The first
    argument, ``detail``, should be a string.  The value of this string will
    be used as the ``message`` attribute of the exception object.  The second
    special keyword argument, ``result`` is usually an instance of
    :class:`pyramid.security.Denied` or
    :class:`pyramid.authorization.ACLDenied` each of which indicates a reason
    for the forbidden error.  However, ``result`` is also permitted to be just
    a plain boolean ``False`` object or ``None``.  The ``result`` value will
    be used as the ``result`` attribute of the exception object.
    It defaults to ``None``.

    The :term:`Forbidden View` can use the attributes of a Forbidden
    exception as necessary to provide extended information in an error
    report shown to a user.
    i  	Forbiddenz#Access was denied to this resource.Nc             K   s&   t j| f||||d| || _d S )N)r   r   r   r   )ro   r   result)r"   r   r   r   r   rv   r#   r   r   r   r     s    	zHTTPForbidden.__init__)NNNNN)r/   r0   r1   rL   r   r   r$   r   r   r   r   r   rt     s       rt   c               @   s   e Zd ZdZdZdZdZdS )HTTPNotFounda  
    subclass of :class:`~HTTPClientError`

    This indicates that the server did not find anything matching the
    Request-URI.

    code: 404, title: Not Found

    Raise this exception within :term:`view` code to immediately
    return the :term:`Not Found View` to the invoking user.  Usually
    this is a basic ``404`` page, but the Not Found View can be
    customized as necessary.  See :ref:`changing_the_notfound_view`.

    This exception's constructor accepts a ``detail`` argument
    (the first argument), which should be a string.  The value of this
    string will be available as the ``message`` attribute of this exception,
    for availability to the :term:`Not Found View`.
    i  z	Not Foundz The resource could not be found.N)r/   r0   r1   rL   r   r   r$   r   r   r   r   rw   "  s   rw   c               @   s    e Zd ZdZdZdZedZdS )HTTPMethodNotAllowedz
    subclass of :class:`~HTTPClientError`

    This indicates that the method specified in the Request-Line is
    not allowed for the resource identified by the Request-URI.

    code: 405, title: Method Not Allowed
    i  zMethod Not AllowedzSThe method ${REQUEST_METHOD} is not allowed for this resource. ${br}${br}
${detail}N)r/   r0   r1   rL   r   r   r   r   r   r   r   r   rx   ;  s
   rx   c               @   s   e Zd ZdZdZdZdS )HTTPNotAcceptablea3  
    subclass of :class:`~HTTPClientError`

    This indicates the resource identified by the request is only
    capable of generating response entities which have content
    characteristics not acceptable according to the accept headers
    sent in the request.

    code: 406, title: Not Acceptable
    i  zNot AcceptableN)r/   r0   r1   rL   r   r   r   r   r   r   ry   Q  s   
ry   c               @   s   e Zd ZdZdZdZdZdS )HTTPProxyAuthenticationRequiredz
    subclass of :class:`~HTTPClientError`

    This is similar to 401, but indicates that the client must first
    authenticate itself with the proxy.

    code: 407, title: Proxy Authentication Required
    i  zProxy Authentication Requiredz,Authentication with a local proxy is needed.N)r/   r0   r1   rL   r   r   r$   r   r   r   r   rz   d  s   rz   c               @   s   e Zd ZdZdZdZdZdS )HTTPRequestTimeoutz
    subclass of :class:`~HTTPClientError`

    This indicates that the client did not produce a request within
    the time that the server was prepared to wait.

    code: 408, title: Request Timeout
    i  zRequest TimeoutzHThe server has waited too long for the request to be sent by the client.N)r/   r0   r1   rL   r   r   r$   r   r   r   r   r{   s  s   r{   c               @   s   e Zd ZdZdZdZdZdS )HTTPConflictz
    subclass of :class:`~HTTPClientError`

    This indicates that the request could not be completed due to a
    conflict with the current state of the resource.

    code: 409, title: Conflict
    i  Conflictz:There was a conflict when trying to complete your request.N)r/   r0   r1   rL   r   r   r$   r   r   r   r   r|     s   r|   c               @   s   e Zd ZdZdZdZdZdS )HTTPGonez
    subclass of :class:`~HTTPClientError`

    This indicates that the requested resource is no longer available
    at the server and no forwarding address is known.

    code: 410, title: Gone
    i  GonezFThis resource is no longer available.  No forwarding address is given.N)r/   r0   r1   rL   r   r   r$   r   r   r   r   r~     s   r~   c               @   s   e Zd ZdZdZdZdZdS )HTTPLengthRequiredz
    subclass of :class:`~HTTPClientError`

    This indicates that the server refuses to accept the request
    without a defined Content-Length.

    code: 411, title: Length Required
    i  zLength RequiredzContent-Length header required.N)r/   r0   r1   rL   r   r   r$   r   r   r   r   r     s   r   c               @   s   e Zd ZdZdZdZdZdS )HTTPPreconditionFailedz
    subclass of :class:`~HTTPClientError`

    This indicates that the precondition given in one or more of the
    request-header fields evaluated to false when it was tested on the
    server.

    code: 412, title: Precondition Failed
    i  zPrecondition FailedzRequest precondition failed.N)r/   r0   r1   rL   r   r   r$   r   r   r   r   r     s   	r   c               @   s   e Zd ZdZdZdZdZdS )HTTPRequestEntityTooLargea   
    subclass of :class:`~HTTPClientError`

    This indicates that the server is refusing to process a request
    because the request entity is larger than the server is willing or
    able to process.

    code: 413, title: Request Entity Too Large
    i  zRequest Entity Too Largez7The body of your request was too large for this server.N)r/   r0   r1   rL   r   r   r$   r   r   r   r   r     s   	r   c               @   s   e Zd ZdZdZdZdZdS )HTTPRequestURITooLongz
    subclass of :class:`~HTTPClientError`

    This indicates that the server is refusing to service the request
    because the Request-URI is longer than the server is willing to
    interpret.

    code: 414, title: Request-URI Too Long
    i  zRequest-URI Too Longz-The request URI was too long for this server.N)r/   r0   r1   rL   r   r   r$   r   r   r   r   r     s   	r   c               @   s   e Zd ZdZdZdZdS )HTTPUnsupportedMediaTypea  
    subclass of :class:`~HTTPClientError`

    This indicates that the server is refusing to service the request
    because the entity of the request is in a format not supported by
    the requested resource for the requested method.

    code: 415, title: Unsupported Media Type
    i  zUnsupported Media TypeN)r/   r0   r1   rL   r   r   r   r   r   r   r     s   	r   c               @   s   e Zd ZdZdZdZdZdS )HTTPRequestRangeNotSatisfiablea  
    subclass of :class:`~HTTPClientError`

    The server SHOULD return a response with this status code if a
    request included a Range request-header field, and none of the
    range-specifier values in this field overlap the current extent
    of the selected resource, and the request did not include an
    If-Range request-header field.

    code: 416, title: Request Range Not Satisfiable
    i  zRequest Range Not Satisfiablez%The Range requested is not available.N)r/   r0   r1   rL   r   r   r$   r   r   r   r   r     s   r   c               @   s   e Zd ZdZdZdZdZdS )HTTPExpectationFailedz
    subclass of :class:`~HTTPClientError`

    This indicates that the expectation given in an Expect
    request-header field could not be met by this server.

    code: 417, title: Expectation Failed
    i  zExpectation FailedzExpectation failed.N)r/   r0   r1   rL   r   r   r$   r   r   r   r   r   	  s   r   c               @   s   e Zd ZdZdZdZdZdS )HTTPUnprocessableEntitya]  
    subclass of :class:`~HTTPClientError`

    This indicates that the server is unable to process the contained
    instructions.

    May be used to notify the client that their JSON/XML is well formed, but
    not correct for the current request.

    See RFC4918 section 11 for more information.

    code: 422, title: Unprocessable Entity
    i  zUnprocessable Entityz,Unable to process the contained instructionsN)r/   r0   r1   rL   r   r   r$   r   r   r   r   r     s   r   c               @   s   e Zd ZdZdZdZdZdS )
HTTPLockedz~
    subclass of :class:`~HTTPClientError`

    This indicates that the resource is locked.

    code: 423, title: Locked
    i  LockedzThe resource is lockedN)r/   r0   r1   rL   r   r   r$   r   r   r   r   r   -  s   r   c               @   s   e Zd ZdZdZdZdZdS )HTTPFailedDependencyz
    subclass of :class:`~HTTPClientError`

    This indicates that the method could not be performed because the
    requested action depended on another action and that action failed.

    code: 424, title: Failed Dependency
    i  zFailed DependencyzsThe method could not be performed because the requested action dependended on another action and that action failedN)r/   r0   r1   rL   r   r   r$   r   r   r   r   r   <  s   r   c               @   s   e Zd ZdZdZdZdZdS )HTTPPreconditionRequireda0  
    subclass of :class:`~HTTPClientError`

    This indicates that the origin server requires the
    request to be conditional.

    Its typical use is to avoid the "lost update" problem, where a client
    GETs a resource's state, modifies it, and PUTs it back to the server,
    when meanwhile a third party has modified the state on the server,
    leading to a conflict.  By requiring requests to be conditional, the
    server can assure that clients are working with the correct copies.

    RFC 6585.3

    code: 428, title: Precondition Required
    i  zPrecondition Requiredz9The origin server requires the request to be conditional.N)r/   r0   r1   rL   r   r   r$   r   r   r   r   r   O  s   r   c               @   s   e Zd ZdZdZdZdZdS )HTTPTooManyRequestsz
    subclass of :class:`~HTTPClientError`

    This indicates that the user has sent too many
    requests in a given amount of time ("rate limiting").

    RFC 6585.4

    code: 429, title: Too Many Requests
    i  zToo Many RequestszUThe action could not be performed because there were too many requests by the client.N)r/   r0   r1   rL   r   r   r$   r   r   r   r   r   f  s   
r   c               @   s   e Zd ZdZdZdZdZdS )HTTPRequestHeaderFieldsTooLargeaE  
    subclass of :class:`~HTTPClientError`

    This indicates that the server is unwilling to process
    the request because its header fields are too large.  The request MAY
    be resubmitted after reducing the size of the request header fields.

    RFC 6585.5

    code: 431, title: Request Header Fields Too Large
    i  zRequest Header Fields Too Largez*The requests header fields were too large.N)r/   r0   r1   rL   r   r   r$   r   r   r   r   r   z  s   r   c               @   s   e Zd ZdZdZdZdS )HTTPServerErrorz
    base class for the 500s, where the server is in-error

    This is an error condition in which the server is presumed to be
    in-error.  Unless specialized, this is a '500 Internal Server Error'.
    i  zInternal Server ErrorN)r/   r0   r1   rL   r   r   r   r   r   r   r     s   r   c               @   s   e Zd ZdZdZdS )HTTPInternalServerErrorz
    subclass of :class:`~HTTPServerError`

    This indicates that the server encountered an unexpected condition
    which prevented it from fulfilling the request.

    code: 500, title: Internal Server Error
    zRThe server has either erred or is incapable of performing the requested operation.N)r/   r0   r1   rL   r$   r   r   r   r   r     s   r   c               @   s   e Zd ZdZdZdZdS )HTTPNotImplementedz
    subclass of :class:`~HTTPServerError`

    This indicates that the server does not support the functionality
    required to fulfill the request.

    code: 501, title: Not Implemented
    i  zNot ImplementedN)r/   r0   r1   rL   r   r   r   r   r   r   r     s   r   c               @   s   e Zd ZdZdZdZdZdS )HTTPBadGatewaya  
    subclass of :class:`~HTTPServerError`

    This indicates that the server, while acting as a gateway or proxy,
    received an invalid response from the upstream server it accessed
    in attempting to fulfill the request.

    code: 502, title: Bad Gateway
    i  zBad GatewayzBad gateway.N)r/   r0   r1   rL   r   r   r$   r   r   r   r   r     s   	r   c               @   s   e Zd ZdZdZdZdZdS )HTTPServiceUnavailablez
    subclass of :class:`~HTTPServerError`

    This indicates that the server is currently unable to handle the
    request due to a temporary overloading or maintenance of the server.

    code: 503, title: Service Unavailable
    i  zService UnavailablezFThe server is currently unavailable. Please try again at a later time.N)r/   r0   r1   rL   r   r   r$   r   r   r   r   r     s   r   c               @   s   e Zd ZdZdZdZdZdS )HTTPGatewayTimeoutaw  
    subclass of :class:`~HTTPServerError`

    This indicates that the server, while acting as a gateway or proxy,
    did not receive a timely response from the upstream server specified
    by the URI (e.g. HTTP, FTP, LDAP) or some other auxiliary server
    (e.g. DNS) it needed to access in attempting to complete the request.

    code: 504, title: Gateway Timeout
    i  zGateway TimeoutzThe gateway has timed out.N)r/   r0   r1   rL   r   r   r$   r   r   r   r   r     s   
r   c               @   s   e Zd ZdZdZdZdZdS )HTTPVersionNotSupportedz
    subclass of :class:`~HTTPServerError`

    This indicates that the server does not support, or refuses to
    support, the HTTP protocol version that was used in the request
    message.

    code: 505, title: HTTP Version Not Supported
    i  zHTTP Version Not Supportedz"The HTTP version is not supported.N)r/   r0   r1   rL   r   r   r$   r   r   r   r   r     s   	r   c               @   s   e Zd ZdZdZdZdZdS )HTTPInsufficientStoragez
    subclass of :class:`~HTTPServerError`

    This indicates that the server does not have enough space to save
    the resource.

    code: 507, title: Insufficient Storage
    i  zInsufficient Storagez/There was not enough space to save the resourceN)r/   r0   r1   rL   r   r   r$   r   r   r   r   r     s   r   c             K   s   t |  f |}|S )zCreates an HTTP exception based on a status code. Example::

        raise exception_response(404) # raises an HTTPNotFound exception.

    The values passed as ``kw`` are provided to the exception's constructor.
    )
status_map)status_coder#   excr   r   r   exception_response  s    r   c             C   s   t | ts|jp| } | S )N)r
   r   rJ   )contextrequestr   r   r   default_exceptionresponse_view"  s    

r   _r   )WrL   r,   stringr   Zwebobr   r7   Zwebob.acceptparser   Zzope.interfacer   Zpyramid.interfacesr   Zpyramid.responser   Zpyramid.utilr   r   r   r   ZWSGIHTTPExceptionrK   rM   rN   rO   rR   rU   rX   rZ   r\   r^   r`   rf   rg   rh   rj   rk   rl   rm   rn   ro   rp   rq   rs   rt   rw   rx   ry   rz   r{   r|   r~   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   listglobalsr;   namer   r
   type
issubclassr<   getattrr   r   r   r   <module>   s   
 B	5A	