Skip to content

Commit

Permalink
Rename option lock_manager to lock_storage
Browse files Browse the repository at this point in the history
  • Loading branch information
mar10 committed Nov 20, 2021
1 parent 8dd3c34 commit 29ff701
Show file tree
Hide file tree
Showing 14 changed files with 37 additions and 32 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
- Drop support for Microsoft Web Folders (option `dir_browser.ms_mount`).
- DAVCollection, DAVNonCollection, DAVProvider are ABCs now
- API enforces some named keyword args (`..., *, ...`)
- Rename option `lock_manager` to `lock_storage`.
- hotfixes.re_encode_path_info is true by default (null evaluates to false now!)
- Deprecate hotfixes.winxp_accept_root_share_login and hotfixes.win_accept_anonymous_options
- Move logging options to 'logging' section
Expand Down
15 changes: 8 additions & 7 deletions docs/source/reference_guide_architecture.rst
Original file line number Diff line number Diff line change
Expand Up @@ -117,18 +117,19 @@ Lock Managers
:parts: 2
:private-bases:

DAV providers may use a lock manager to support exclusive and shared write
locking.
DAV providers have a :class:`~wsgidav.lock_manager.LockManager` to support
exclusive and shared write locking.
The lock manager uses a lock storage implementation for persistence.

WsgiDAV comes with two default implementations, one based on a in-memory
dictionary, and a persistent one based on shelve::

lock_manager.LockManager
lock_manager.ShelveLockManager
lock_storage.LockStorage
lock_storage.ShelveLockStorage

:class:`~wsgidav.property_manager.LockManager` is used by default, but
:class:`~wsgidav.property_manager.ShelveLockManager` can be
enabled by uncommenting two lines in the configuration file.
:class:`~wsgidav.lock_storage.LockStorage` is used by default, but
:class:`~wsgidav.lock_storage.ShelveLockStorage` can be enabled by uncommenting
two lines in the configuration file.

In addition, this may be replaced by a custom version, as long as the required
interface is implemented.
Expand Down
10 changes: 5 additions & 5 deletions sample_wsgidav.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -207,19 +207,19 @@ mutable_live_props:
- "{DAV:}getlastmodified"

# ----------------------------------------------------------------------------
# Lock Manager
# Lock Manager Storage
#
# Default: true, i.e. use wsgidav.lock_storage.LockStorageDict
# Also available: wsgidav.lock_storage.LockStorageShelve
#
# Check the documentation on how to develop custom lock managers.
# Check the documentation on how to develop custom lock storage.
# Note that the default LockStorageDict works in-memory, so it is NOT
# persistent.
# Example:
# Use PERSISTENT shelve based lock manager
# Use PERSISTENT shelve based lock storage
# from wsgidav.lock_storage import LockStorageShelve
# lock_manager = LockStorageShelve("wsgidav-locks.shelve")
lock_manager: true
# lock_storage = LockStorageShelve("wsgidav-locks.shelve")
lock_storage: true



Expand Down
5 changes: 3 additions & 2 deletions tests/davclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,11 +151,12 @@ def _request(self, method, path="", body=None, headers=None):
# Try to parse and get an etree
try:
self._get_response_tree()
except Exception:
pass
except Exception as e:
self.log(f"Could not parse response XML: {e}\n{res.text}")

def _get_response_tree(self):
"""Parse the response body into an elementree object"""
self.response.tree = None
self.response.tree = ElementTree.fromstring(self.response.content)
return self.response.tree

Expand Down
4 changes: 2 additions & 2 deletions tests/test_scripted.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,8 @@ def run(self):
],
"debug_methods": [],
},
"property_manager": True, # True: use lock_manager.LockManager
"lock_manager": True, # True: use lock_manager.LockManager
"property_manager": True, # True: use property_manager.PropertyManager
"lock_storage": True, # True: use LockManager(lock_storage.LockStorageDict)
}

if withAuthentication:
Expand Down
2 changes: 1 addition & 1 deletion tests/test_wsgidav_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def _makeWsgiDAVApp(self, share_path, with_authentication):
"verbose": 1,
"logging": {"enable_loggers": []},
"property_manager": None, # None: no property manager
"lock_manager": True, # True: use lock_manager.LockManager
"lock_storage": True, # True: use LockManager(lock_storage.LockStorageDict)
}

if with_authentication:
Expand Down
4 changes: 2 additions & 2 deletions tests/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ def run_wsgidav_server(with_auth, with_ssl, provider=None, **kwargs):
"enable_loggers": [],
# "debug_methods": [],
},
"property_manager": True, # None: no property manager
"lock_manager": True, # True: use lock_manager.LockManager
"property_manager": True, # True: use property_manager.PropertyManager
"lock_storage": True, # True: use LockManager(lock_storage.LockStorageDict)
}

if with_auth:
Expand Down
2 changes: 1 addition & 1 deletion tests/wsgidav-litmus.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,4 @@ mutable_live_props:
# preserve-timestamp flags in a mounted DAV share (may be RFC4918 incompliant)
- "{DAV:}getlastmodified"

lock_manager: true
lock_storage: true
9 changes: 6 additions & 3 deletions wsgidav/dav_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,16 @@
using shelve.
lockManager
An object that implements locking on webDAV resources.
It contains an instance of ``LockStorage``
lockStorage
An object that provides storage for locks made on webDAV resources.
LockManagers must provide the methods as described in
LockStorages must provide the methods as described in
``wsgidav.interfaces.lockmanagerinterface``
See lock_manager.LockManager for a sample implementation
using shelve.
See lock_storage for a sample implementation using shelve.
See :doc:`reference_guide` for more information about the WsgiDAV architecture.
"""
Expand Down
2 changes: 1 addition & 1 deletion wsgidav/default_conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
},
"property_manager": None, # True: use property_manager.PropertyManager
"mutable_live_props": [],
"lock_manager": True, # True: use lock_manager.LockManager
"lock_storage": True, # True: use LockManager(lock_storage.LockStorageDict)
"middleware_stack": [
WsgiDavDebugFilter,
ErrorPrinter,
Expand Down
5 changes: 0 additions & 5 deletions wsgidav/lock_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,11 +158,6 @@ def _dump(self, msg=""):
ownerDict.setdefault(lock["owner"], []).append(tok)
urlDict.setdefault(lock["root"], []).append(tok)

# assert ("URL2TOKEN:" + v["root"]) in self._dict, ("Inconsistency: missing"
# "URL2TOKEN:%s") % v["root"]
# assert v["token"] in self._dict["URL2TOKEN:" + v["root"]], ("Inconsistency: missing "
# "token %s in URL2TOKEN:%s" % (v["token"], v["root"])

_logger.info("Locks:\n{}".format(pformat(tokenDict, indent=0, width=255)))
if tokenDict:
_logger.info(
Expand Down
4 changes: 3 additions & 1 deletion wsgidav/lock_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
(dict-based), and one persistent low performance variant using shelve.
See :class:`~wsgidav.lock_manager.LockManager`
See :class:`~wsgidav.lock_storage.LockStorageDict`
See :class:`~wsgidav.lock_storage.LockStorageShelve`
"""
import os
import shelve
Expand Down Expand Up @@ -54,7 +56,7 @@ class LockStorageDict:
members is done by re-assignment and we call a _flush() method.
This is obviously not persistent, but should be enough in some cases.
For a persistent implementation, see lock_manager.LockStorageShelve().
For a persistent implementation, see lock_storage.LockStorageShelve().
Notes:
expire is stored as expiration date in seconds since epoch (not in
Expand Down
2 changes: 1 addition & 1 deletion wsgidav/server/server_sample.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def main():
"enable_loggers": [],
},
"property_manager": True, # True: use property_manager.PropertyManager
"lock_manager": True, # True: use lock_manager.LockManager
"lock_storage": True, # True: use LockManager(lock_storage.LockStorageDict)
}
app = WsgiDAVApp(config)

Expand Down
4 changes: 3 additions & 1 deletion wsgidav/wsgidav_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ def _check_config(config):
"http_authenticator.preset_domain": "nt_dc.preset_domain",
"http_authenticator.preset_server": "nt_dc.preset_server",
"locksmanager": "lock_manager",
"lock_manager": "lock_storage",
"logger_date_format": "logging.logger_date_format",
"logger_format": "logging.logger_format",
"logging.verbose": "verbose", # prevent a likely mistake
Expand Down Expand Up @@ -148,13 +149,14 @@ def __init__(self, config):
self.re_encode_path_info = hotfixes.get("re_encode_path_info", True)
self.unquote_path_info = hotfixes.get("unquote_path_info", False)

lock_storage = config.get("lock_manager")
lock_storage = config.get("lock_storage")
if lock_storage is True:
lock_storage = LockStorageDict()

if not lock_storage:
self.lock_manager = None
else:
assert hasattr(lock_storage, "refresh")
self.lock_manager = LockManager(lock_storage)

self.prop_manager = config.get("property_manager")
Expand Down

0 comments on commit 29ff701

Please sign in to comment.