
# Note: This file is in Python syntax and format

################################################################################
# WsgiDAV configuration file
# 
################################################################################
# INITIALIZATION - Do not modify this section

provider_mapping = {}
user_mapping = {}


def addShare(shareName, davProvider):
    provider_mapping[shareName] = davProvider

    
def addUser(realmName, user, password, description, roles=[]):
    realmName = "/" + realmName.strip(r"\/")
    userDict = user_mapping.setdefault(realmName, {}).setdefault(user, {})
    userDict["password"] = password
    userDict["description"] = description
    userDict["roles"] = roles

        
################################################################################
# SERVER OPTIONS
#===============================================================================
# 3rd party servers
# Try to run WsgiDAV inside these WSGI servers, in that order
ext_servers = (
#              "paste", 
#              "cherrypy",
#              "wsgiref",
               "cherrypy-bundled",
               "wsgidav",
               )


#===============================================================================
# Debugging

verbose = 2          # 0 - no output (excepting application exceptions)         
                     # 1 - show single line request summaries (HTTP logging)
                     # 2 - show additional events
                     # 3 - show full request/response header info (HTTP Logging)
                     #     request body and GET response bodies not shown


# Enable specific module loggers
# E.g. ["lock_manager", "property_manager", "http_authenticator", ...]

enable_loggers = []


################################################################################
# WsgiDavDirBrowser

dir_browser = {
    "enable": True,          # Render HTML listing for GET requests on collections
    "response_trailer": "",  # Raw HTML code, appended as footer
    "davmount": False,       # Send <dm:mount> response if request URL contains '?davmount'
    "msmount": False,        # Add an 'open as webfolder' link (requires Windows)
#    "app_class": MyBrowser, # Used instead of WsgiDavDirBrowser
}


################################################################################
# DAV Provider

#===============================================================================
# Property Manager
#
# Uncomment this lines to specify your own property manager.
# Default:        no support for dead properties
# Also available: wsgidav.property_manager.PropertyManager
#                 wsgidav.property_manager.ShelvePropertyManager
#
# Check the documentation on how to develop custom property managers.
# Note that the default PropertyManager works in-memory, and thus is NOT 
# persistent.

### Use in-memory property manager (NOT persistent)
# (this is the same as passing 'propsmanager = True')
#from wsgidav.property_manager import PropertyManager
#propsmanager = PropertyManager()

### Use persistent shelve based property manager
#from wsgidav.property_manager import ShelvePropertyManager
#propsmanager = ShelvePropertyManager("wsgidav-props.shelve")

### Use persistent MongoDB based property manager
#from wsgidav.addons.mongo_property_manager import MongoPropertyManager
#prop_man_opts = {}
#propsmanager = MongoPropertyManager(prop_man_opts)

### Use persistent CouchDB based property manager
#from wsgidav.addons.couch_property_manager import CouchPropertyManager
#prop_man_opts = {}
#propsmanager = CouchPropertyManager(prop_man_opts)

### Use in-memory property manager (NOT persistent)
propsmanager = True


#===============================================================================
# Lock Manager
#
# Uncomment this lines to specify your own locks manager.                    
# Default:        wsgidav.lock_storage.LockStorageDict
# Also available: wsgidav.lock_storage.LockStorageShelve
#
# Check the documentation on how to develop custom lock managers.
# Note that the default LockStorageDict works in-memory, and thus is NOT 
# persistent.
                 
# Example: Use in-memory lock storage
#          (this is the same as passing 'locksmanager = True', which is default)
#from wsgidav.lock_storage import LockStorageDict
#locksmanager = LockStorageDict()


# Example: Use PERSISTENT shelve based lock manager
#from wsgidav.lock_storage import LockStorageShelve
#locksmanager = LockStorageShelve("wsgidav-locks.shelve")


#===============================================================================
# SHARES
#
# If you would like to publish files in the location '/v_root' through a
# WsgiDAV share 'files', so that it can be accessed by this URL:  
#     http://server:port/files 
# insert the following line:
#     addShare("files", "/v_root")
# or, on a Windows box:
#     addShare("files", "c:\\v_root")
#
# To access the same directory using a root level share 
#     http://server:port/
# insert this line: 
#     addShare("", "/v_root")
#
# The above examples use wsgidav.fs_dav_provider.FilesystemProvider, which is 
# the default provider implementation.
# 
# If you wish to use a custom provider, an object must be passed as second 
# parameter. See the examples below.  

### Add a read-write file share: 
addShare("dav", r"C:\temp")

### Add a read-only file share: 
#from wsgidav.fs_dav_provider import FilesystemProvider
#addShare("tmp", FilesystemProvider("/tmp", readonly=True))


### Publish an MySQL 'world' database as share '/world-db' 
#from wsgidav.addons.mysql_dav_provider import MySQLBrowserProvider
#addShare("world-db", MySQLBrowserProvider("localhost", "root", "test", "world"))


### Publish a virtual structure
#from wsgidav.samples.virtual_dav_provider import VirtualResourceProvider
#addShare("virtres", VirtualResourceProvider())


### Publish a Mercurial repository
#from wsgidav.addons.hg_dav_provider import HgResourceProvider
#addShare("hg", HgResourceProvider("PATH_OR_URL"))


### Publish a MongoDB
#from wsgidav.samples.mongo_dav_provider import MongoResourceProvider
#mongo_dav_opts = {}
#addShare("mongo", MongoResourceProvider(mongo_dav_opts))


################################################################################
# AUTHENTICATION
#===============================================================================
# HTTP Authentication Options

acceptbasic = True    # Allow basic authentication, True or False
acceptdigest = True   # Allow digest authentication, True or False
defaultdigest = True  # True (default digest) or False (default basic)


#domaincontroller =   # Uncomment this line to specify your own domain controller
                      # Default: wsgidav.domain_controller, which uses the USERS 
                      #          section below


# Example: use a domain controller that allows users to authenticate against 
#          a Windows NT domain or a local computer.
#          Note: NTDomainController requires basic authentication:
#                Set acceptbasic=True, acceptdigest=False, defaultdigest=False 

#from wsgidav.addons.nt_domain_controller import NTDomainController
#domaincontroller = NTDomainController(presetdomain=None, presetserver=None)
#acceptbasic = True
#acceptdigest = False
#defaultdigest = False


#===============================================================================
# USERS
#
# This section is ONLY used by the DEFAULT Domain Controller.
#
# Users are defined per realm: 
#     addUser(<realm>, <user>, <password>, <description>)  
#
# Note that the default Domain Controller uses the share name as realm name.   
# 
# If no users are specified for a realm, no authentication is required.
# Thus granting read-write access to anonymous! 
#
# Note: If you wish to use Windows WebDAV support (such as Windows XP's My 
# Network Places), you need to include the domain of the user as part of the 
# username (note the DOUBLE slash), such as:
# addUser("v_root", "domain\\user", "password", "description")

addUser("", "tester", "tester", "")
addUser("", "tester2", "tester2", "")

#addUser("dav", "tester", "tester", "")
#addUser("dav", "tester2", "tester2", "")

#addUser("virtres", "tester", "tester", "")
