
    qiq"                     z    S r SSKJr  SSKJrJr  SSKJr  SSKJ	r	  Sr
\R                  " \5      r " S S\5      rg	)
a  
WSGI middleware that finds the registered mapped DAV-Provider, creates a new
RequestServer instance, and dispatches the request.

.. warning::
   The following documentation was taken over from PyFileServer and is outdated.

WsgiDAV file sharing
--------------------

WsgiDAV allows the user to specify in wsgidav.conf a number of
realms, and a number of users for each realm.

Realms
   Each realm corresponds to a filestructure on disk to be stored,
   for example::

      addShare('pubshare','/home/public/share')

   would allow the users to access using WebDAV the directory/file
   structure at /home/public/share from the url
   http://<servername:port>/<approot>/pubshare

   The realm name is set as '/pubshare'

   e.g. /home/public/share/WsgiDAV/LICENSE becomes accessible as
   http://<servername:port>/<approot>/pubshare/WsgiDAV/LICENSE

Users
   A number of user_name/password pairs can be set for each realm::

      adduser('pubshare', 'user_name', 'password', 'description/unused')

   would add a user_name/password pair to realm /pubshare.

Note: if developers wish to maintain a separate users database, you can
write your own domain controller for the HTTPAuthenticator. See
http_authenticator.py and domain_controller.py for more details.


Request Resolver
----------------

WSGI middleware for resolving Realm and Paths for the WsgiDAV
application.

Usage::
   It *must* be configured as the last item on `middleware_stack` list.

   from wsgidav.request_resolver import RequestResolver
   config = {
        ...,
        'middleware_stack': [
            ...,
            RequestResolver,
        ],
    }

The RequestResolver resolves the requested URL to the following values
placed in the environ dictionary. First it resolves the corresponding
realm::

   url: http://<servername:port>/<approot>/pubshare/WsgiDAV/LICENSE
   environ['wsgidav.mappedrealm'] = /pubshare

Based on the configuration given, the resource abstraction layer for the
realm is determined. if no configured abstraction layer is found, the
default abstraction layer fileabstractionlayer.FilesystemAbstractionLayer()
is used::

   environ['wsgidav.resourceAL'] = fileabstractionlayer.MyOwnFilesystemAbstractionLayer()

The path identifiers for the requested url are then resolved using the
resource abstraction layer::

   environ['wsgidav.mappedpath'] = /home/public/share/WsgiDAV/LICENSE
   environ['wsgidav.mappedURI'] = /pubshare/WsgiDAV/LICENSE

in this case, FilesystemAbstractionLayer resolves any relative paths
to its canonical absolute path

The RequestResolver also resolves any value in the Destination request
header, if present, to::

   Destination: http://<servername:port>/<approot>/pubshare/WsgiDAV/LICENSE-dest
   environ['wsgidav.destrealm'] = /pubshare
   environ['wsgidav.destpath'] = /home/public/share/WsgiDAV/LICENSE-dest
   environ['wsgidav.destURI'] = /pubshare/WsgiDAV/LICENSE
   environ['wsgidav.destresourceAL'] = fileabstractionlayer.MyOwnFilesystemAbstractionLayer()

    )util)HTTP_NOT_FOUNDDAVError)BaseMiddleware)RequestServerreStructuredTextc                   .   ^  \ rS rSrU 4S jrS rSrU =r$ )RequestResolver   c                 &   > [         TU ]  XU5        g )N)super__init__)selfwsgidav_appnext_appconfig	__class__s       M/home/kali/flask_env/lib/python3.13/site-packages/wsgidav/request_resolver.pyr   RequestResolver.__init__   s    7    c              #     #    US   nUS   nUS   n[         R                  " USSS9nUS   S:H  =(       a    US	:H  nUS
:X  a0  UR                  S5      nU(       a  SnO[        R	                  S5        U(       a  Sn	Ub"  UR                  5       (       d  UR                  c  Sn	SSSU	4S[         R                  " 5       4/n
US   R                  SS5      (       a  U
R                  S5        U" SU
5        Sv   g Uc  [        [        SU< 35      e[        U5      nU" X5      nU S h  vN   [        US5      (       a  UR                  5         g  N&7f)N	PATH_INFOzwsgidav.providerzwsgidav.confighotfixesT)as_dictREQUEST_METHODOPTIONS*/treat_root_options_as_asteriskzGot OPTIONS '/' requestz1,21)zContent-Typeztext/html; charset=utf-8)zContent-Length0DAVDateadd_header_MS_Author_ViaF)zMS-Author-Viar"   z200 OKr   z%Could not find resource provider for close)r   get_dict_valueget_loggerinfois_readonlylock_managerget_rfc1123_timeappendr   r   r   hasattrr%   )r   environstart_responsepathproviderr   r   is_asterisk_optionstreat_as_asteriskdav_compliance_levelheadersappapp_iters                r   __call__RequestResolver.__call__   sy    {#
 -.)*&&vz4H%&679DTQT3; (-M N &*#67 $)   ''))((0'*$ =',-..01	G '(,,-GOO788W-I"Gx P  H%w/8W%%NN	 	s   D%E'E('E )__name__
__module____qualname____firstlineno__r   r9   __static_attributes____classcell__)r   s   @r   r
   r
      s    8C Cr   r
   N)__doc__wsgidavr   wsgidav.dav_errorr   r   wsgidav.mw.base_mwr   wsgidav.request_serverr   __docformat__get_module_loggerr<   r(   r
   r;   r   r   <module>rI      s>   
Zv  6 - 0"

 
 
*lGn Gr   