# (c) 2009-2016 Martin Wendt and contributors; see WsgiDAV https://github.com/mar10/wsgidav
# Original PyFileServer (c) 2005 Ho Chun Wei.
# Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php
"""
Simple example how to a run WsgiDAV in a 3rd-party WSGI server.
"""
from tempfile import gettempdir
from wsgidav import __version__
from wsgidav.fs_dav_provider import FilesystemProvider
from wsgidav.wsgidav_app import DEFAULT_CONFIG, WsgiDAVApp

__docformat__ = "reStructuredText"


rootpath = gettempdir()
provider = FilesystemProvider(rootpath)

config = DEFAULT_CONFIG.copy()
config.update({
    "provider_mapping": {"/": provider},
    "user_mapping": {},
    "verbose": 1,
    "enable_loggers": [],
    "propsmanager": True,      # True: use property_manager.PropertyManager                    
    "locksmanager": True,      # True: use lock_manager.LockManager                   
    "domaincontroller": None,  # None: domain_controller.WsgiDAVDomainController(user_mapping)
    })
app = WsgiDAVApp(config)

# For an example. use paste.httpserver
# (See http://pythonpaste.org/modules/httpserver.html for more options)
from paste import httpserver
httpserver.serve(app, 
                 host="localhost", 
                 port=8080,
                 server_version="WsgiDAV/%s" % __version__,
                 )

# Or we could use default the server that is part of the WsgiDAV package:
#from wsgidav.server import ext_wsgiutils_server
#ext_wsgiutils_server.serve(config, app)

@@ -516,18 +516,33 @@
 ext%22%0D%0A%0D%0A
-%0D%0A
+def main():%0D%0A    
 rootpath
@@ -558,16 +558,20 @@
 pdir()%0D%0A
+    
 provider
@@ -605,16 +605,20 @@
 ath)%0D%0A%0D%0A
+    
 config =
@@ -641,16 +641,20 @@
 copy()%0D%0A
+    
 config.u
@@ -662,16 +662,20 @@
 date(%7B%0D%0A
+    
     %22pro
@@ -704,24 +704,28 @@
 provider%7D,%0D%0A
+    
     %22user_ma
@@ -733,24 +733,28 @@
 ping%22: %7B%7D,%0D%0A
+    
     %22verbose
@@ -760,16 +760,20 @@
 e%22: 1,%0D%0A
+    
     %22ena
@@ -791,24 +791,28 @@
 %22: %5B%5D,%0D%0A    
+   
+ 
 %22propsmanage
@@ -888,24 +888,28 @@
           %0D%0A
+    
     %22locksma
@@ -988,16 +988,20 @@
   %0D%0A    
+ 
+   
 %22domainc
@@ -1092,12 +1092,20 @@
     
+   
+ 
 %7D)%0D%0A
+    
 app 
@@ -1128,16 +1128,20 @@
 fig)%0D%0A%0D%0A
+    
 # For an
@@ -1148,17 +1148,470 @@
  example
-.
+, use CherryPy%0D%0A    from cherrypy.wsgiserver import CherryPyWSGIServer%0D%0A%0D%0A    server = CherryPyWSGIServer(%0D%0A        bind_addr=(config%5B%22host%22%5D, config%5B%22port%22%5D),%0D%0A        wsgi_app=app,%0D%0A        server_name=%22WsgiDAV/%25s %25s%22 %25 (__version__, CherryPyWSGIServer.version),%0D%0A        )%0D%0A%0D%0A    try:%0D%0A        server.start()%0D%0A    except KeyboardInterrupt:%0D%0A        print(%22Caught Ctrl-C, shutting down...%22)%0D%0A    finally:%0D%0A        server.stop()%0D%0A%0D%0A    # For an example,
  use pas
@@ -1625,16 +1625,20 @@
 server%0D%0A
+    
 # (See h
@@ -1702,16 +1702,21 @@
 tions)%0D%0A
+#    
 from pas
@@ -1737,16 +1737,21 @@
 server%0D%0A
+#    
 httpserv
@@ -1762,24 +1762,25 @@
 erve(app, %0D%0A
+#
             
@@ -1784,16 +1784,20 @@
         
+    
 host=%22lo
@@ -1808,16 +1808,18 @@
 ost%22, %0D%0A
+# 
         
@@ -1827,16 +1827,19 @@
         
+   
 port=808
@@ -1842,16 +1842,18 @@
 =8080,%0D%0A
+# 
         
@@ -1857,24 +1857,27 @@
             
+   
 server_versi
@@ -1908,16 +1908,21 @@
 ion__,%0D%0A
+#    
         
@@ -1939,171 +1939,46 @@
 %0D%0A%0D%0A
-# Or we could use default the server that is part of the WsgiDAV package:%0D%0A#from wsgidav.server import ext_wsgiutils_server%0D%0A#ext_wsgiutils_server.serve(config, app
+%0D%0Aif __name__ == %22__main__%22:%0D%0A    main(
 )%0D%0A

Update sample server to use CherryPy