• File: urlmap.cpython-37.pyc
  • Full Path: /home3/farmfre2/public_html/ALFA_DATA/alfasymlink/root/opt/alt/python37/lib/python3.7/site-packages/paste/__pycache__/urlmap.cpython-37.pyc
  • Date Modified: 12/01/2019 7:09 PM
  • File size: 7.97 KB
  • MIME-type: text/x-bytecode.python
  • Charset: 8 bit
B

bNH#@spdZddlmZddlZddlZddlZddlmZddgZddZ	d	d
Z
GdddeZGdddeZ
dS)
z8
Map URL prefixes to WSGI applications.  See ``URLMap``
)	DictMixinN)httpexceptionsURLMapPathProxyURLMapcKsrd|kr|d}n
|d}|r0|j||d}t|d}x2|D]&\}}t|}|j||d}|||<qDW|S)N
not_found_app)global_conf)r)popgetZget_appritemsparse_path_expression)loaderrZ
local_confrZurlmappathZapp_nameappr=/opt/alt/python37/lib/python3.7/site-packages/paste/urlmap.pyurlmap_factorys

rcCs|}d}}}x|r|ddkrT|d|s<td|rHtd|d}q|ddkr|d|svtd|rtd|d}q|rtd	||df|d}qWd
}|rd|}|r|std|d
|7}|r|r|d7}||7}|S)z
    Parses a path expression like 'domain foobar.com port 20 /' or
    just '/foobar' for a path alone.  Returns as an address that
    URLMap likes.
    Nrdomainz,'domain' must be followed with a domain namez'domain' given twiceportz*'port' must be followed with a port numberz'port' given twicez*more than one path given (have %r, got %r)z	http://%sz/If you give a port, you must also give a domain:/)splitr
ValueError)r
partsrrsrrrrsB

rc@speZdZdZdddZedZedZddZ	dd
dZ
dd
ZddZddZ
ddZddZddZdS)ra
    URLMap instances are dictionary-like object that dispatch to one
    of several applications based on the URL.

    The dictionary keys are URLs to match (like
    ``PATH_INFO.startswith(url)``), and the values are applications to
    dispatch to.  URLs are matched most-specific-first, i.e., longest
    URL first.  The ``SCRIPT_NAME`` and ``PATH_INFO`` environmental
    variables are adjusted to indicate the new context.

    URLs can also include domains, like ``http://blah.com/foo``, or as
    tuples ``('blah.com', '/foo')``.  This will match domain names; without
    the ``http://domain`` or with a domain of ``None`` any domain will be
    matched (so long as no other explicit domain matches).  NcCsg|_|s|j}||_dS)N)applicationsrnot_found_application)selfrrrr__init__WszURLMap.__init__z//+z^(http|https)://cCs|d}|r4dd|jD}ddtt|}nd}|d|d7}|d	|d
7}|d|d7}tj|d
t|d
j	}|||S)Nzpaste.urlmap_objectcSsg|]\}}|qSrr).0parrr
<listcomp>csz(URLMap.not_found_app.<locals>.<listcomp>zdefined apps: %sz,
  rz
SCRIPT_NAME: %rSCRIPT_NAMEz
PATH_INFO: %r	PATH_INFOz
HTTP_HOST: %r	HTTP_HOST)comment)
r	rjoinmapreprrZHTTPNotFoundcgiescapeZwsgi_application)renvironstart_responseZmappermatchesextrarrrrr`s
zURLMap.not_found_appTcCst|ttfr0|d}||dd}||fS|rV|dsV|j|sVtd||j|}|r||d}d|kr|	dd\}}d|}q|d}}nd}|j
d|}|r|d}||fS)Nrrz8URL fragments must start with / or http:// (you gave %r)r)
isinstancelisttuple
normalize_url
startswith
domain_url_researchAssertionErrorendrnorm_url_resubrstrip)rurlZtrimrmatchrrrr4ps&


zURLMap.normalize_urlcs8ddfdd|jD}|dd|D|_dS)zK
        Make sure applications are sorted with longest URLs first
        cSs0|\\}}}|sdt|fS|t|fSdS)NΓΏ)len)Zapp_descrr=rrrrkeyszURLMap.sort_apps.<locals>.keycsg|]}||fqSrr)rdesc)rArrr"sz$URLMap.sort_apps.<locals>.<listcomp>cSsg|]\}}|qSrr)rZsortablerBrrrr"sN)rsort)rZappsr)rAr	sort_appsszURLMap.sort_appscCs`|dkr,y
||=Wntk
r&YnXdS||}||krD||=|j||f|dS)N)KeyErrorr4rappendrD)rr=rdom_urlrrr__setitem__s

zURLMap.__setitem__cCsN||}x|jD]\}}||kr|SqWtd|d|dp>d|jfdS)Nz9No application with the url %r (domain: %r; existing: %s)r0r*)r4rrE)rr=rGapp_urlrrrr__getitem__s
zURLMap.__getitem__cCsJ||}x:|jD]"\}}||kr|j||fPqWtd|fdS)NzNo application with the url %r)r4rremoverE)rr=rJrrrr__delitem__s
zURLMap.__delitem__cCsdd|jDS)NcSsg|]\}}|qSrr)rrJrrrrr"szURLMap.keys.<locals>.<listcomp>)r)rrrrkeysszURLMap.keysc	Cs|d|d}d|kr0|dd\}}n|ddkrBd}nd}|d	}||d
d}xx|jD]n\\}}}|r||kr||d|krqh||ks||drh|d|7<|t|d|d	<|||SqhW||d
<|||S)Nr%ZSERVER_NAMErr0zwsgi.url_schemehttpZ80Z443r$Frr#zpaste.urlmap_object)r	lowerrr4rr5r@r)	rr,r-hostrZ	path_inforrJrrrr__call__s$
zURLMap.__call__)N)T)__name__
__module____qualname____doc__rrecompiler:r6rr4rDrHrKrMrNrRrrrrrFs




	
c@sBeZdZdZddZddZddZdd	Zd
dZe	eeZ
dS)
ra
    This is a wrapper for URLMap that catches any strings that
    are passed in as applications; these strings are treated as
    filenames (relative to `base_path`) and are passed to the
    callable `builder`, which will return an application.

    This is intended for cases when configuration files can be
    treated as applications.

    `base_paste_url` is the URL under which all applications added through
    this wrapper must go.  Use ``""`` if you want this to not
    change incoming URLs.
    cCs$||_|j||_||_||_dS)N)r(r4base_paste_url	base_pathbuilder)rr(rYrZr[rrrrszPathProxyURLMap.__init__cCsft|ttfr(tj|j|}||}|j	|}|dpD|j
d|j
d|df}||j|<dS)Nrr0)r1strunicodeosr
r'rZr[r(r4rY)rr=rZapp_fnrrrrHs
zPathProxyURLMap.__setitem__cCst|j|S)N)getattrr()rattrrrr__getattr__szPathProxyURLMap.__getattr__cCs|jjS)N)r(r)rrrrnot_found_application__getsz*PathProxyURLMap.not_found_application__getcCs||j_dS)N)r(r)rvaluerrrnot_found_application__setsz*PathProxyURLMap.not_found_application__setN)rSrTrUrVrrHrarbrdpropertyrrrrrrs)rVUserDictrrWr^r*paster__all__rrrobjectrrrrr<module>s)