Skip to content
Snippets Groups Projects
Verified Commit 817c67a2 authored by Ubbo Veentjer's avatar Ubbo Veentjer
Browse files

refactor: dav provider refactoring cont'd

parent 5bef02de
No related branches found
Tags v5.0.0
1 merge request!17Resolve "refactor dav and named_dav providers to duplicate less code"
......@@ -26,15 +26,15 @@ class TextgridRoot(DAVCollection):
def __init__(self, path, environ):
DAVCollection.__init__(self, path, environ)
self._sid = environ["wsgidav.auth.user_name"]
config = TextgridConfig()
self._auth = TextgridAuth(config)
def get_display_info(self):
return {"type": "Textgrid root collection"}
def get_member_names(self):
_logger.debug("Called TextgridRoot.get_member_names(self).")
config = TextgridConfig()
auth = TextgridAuth(config)
projects = tuple(auth.list_assigned_projects(self._sid))
projects = tuple(self._auth.list_assigned_projects(self._sid))
_logger.debug("MY PROJECTS: %s", projects)
return projects
......@@ -79,8 +79,9 @@ class TextgridProject(DAVCollection):
_logger.debug("Called TextgridProject.__init__(self, %s, environ).", path)
DAVCollection.__init__(self, path, environ)
self._sid = environ["wsgidav.auth.user_name"]
self._tgconfig = TextgridConfig()
self._tgsearch = TextgridSearch(self._tgconfig.search)
config = TextgridConfig()
self._tgsearch = TextgridSearch(config.search)
self._project_id = self.path.split("/")[-1]
def create_empty_resource(self, name):
pass
......@@ -100,7 +101,7 @@ class TextgridProject(DAVCollection):
# return names
#
# path resolution has to be rewritten before we can work with resource titles
response = self._tgsearch.list_project_root(self.path.split("/")[-1], self._sid)
response = self._tgsearch.list_project_root(self.project_id, self._sid)
names = []
for result in response.result:
names.append(result.object_value.generic.generated.textgrid_uri.value)
......@@ -170,8 +171,8 @@ class TextgridAggregation(DAVCollection):
DAVCollection.__init__(self, path, environ)
self._sid = environ["wsgidav.auth.user_name"]
self._info = info
self._tgconfig = TextgridConfig()
self._tgsearch = TextgridSearch(self._tgconfig.search)
config = TextgridConfig()
self._tgsearch = TextgridSearch(config.search)
self._tguri = self.path.split("/")[-1]
def create_empty_resource(self, name):
......
import logging
from pprint import pformat
from tgclients.config import TextgridConfig
from tgclients.crud import TextgridCRUD
from tgclients.metadata import TextgridMetadata
from tgclients.auth import TextgridAuth
from wsgidav.util import join_uri
from repdav.stream_tools import FileLikeQueue
from repdav.textgrid_dav_provider import (
TextgridAggregation,
TextgridProject,
......@@ -43,10 +39,7 @@ class TextgridNamedRoot(TextgridRoot):
"""
def __init__(self, path, environ):
# TODO: do not overwrite but move to parent class
super().__init__(path, environ)
config = TextgridConfig()
self._auth = TextgridAuth(config)
def get_member_names(self):
_logger.debug("Called TextgridNamedRoot.get_member_names(self).")
......@@ -68,13 +61,13 @@ class TextgridNamedProject(TextgridProject):
_logger.debug("Called TextgridNamedProject.__init__(self, %s, environ).", path)
super().__init__(path, environ)
self._tgmeta = TextgridMetadata()
name = self.path.split("/")[-1]
# the projectID is found between square brackets at the end of the name string
self._project_id = name[name.rfind("[") + 1 : name.rfind("]")]
def get_member_names(self):
_logger.debug("Called TextgridNamedProject.get_member_names(self).")
name = self.path.split("/")[-1]
# the projectID is found between square brackets at the end of the name string
project_id = name[name.rfind("[") + 1 : name.rfind("]")]
response = self._tgsearch.list_project_root(project_id, self._sid)
response = self._tgsearch.list_project_root(self._project_id, self._sid)
names = []
for result in response.result:
names.append(self._tgmeta.filename_from_metadata(result))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment