INSTRUCTION stringlengths 1 8.43k | RESPONSE stringlengths 75 104k |
|---|---|
returns a single resource object. Will return None if no resource is found. Will raise an error if more than one resource with the same name is found. | def get_resource(self, name=None, store=None, workspace=None):
'''
returns a single resource object.
Will return None if no resource is found.
Will raise an error if more than one resource with the same name is found.
'''
resources = self.get_resources(names=name, ... |
names and workspaces can be provided as a comma delimited strings or as arrays and are used for filtering. If no workspaces are provided will return all layer groups in the catalog ( global and workspace specific ). Will always return an array. | def get_layergroups(self, names=None, workspaces=None):
'''
names and workspaces can be provided as a comma delimited strings or as arrays, and are used for filtering.
If no workspaces are provided, will return all layer groups in the catalog (global and workspace specific).
Will always ... |
returns a single layergroup object. Will return None if no layergroup is found. Will raise an error if more than one layergroup with the same name is found. | def get_layergroup(self, name, workspace=None):
'''
returns a single layergroup object.
Will return None if no layergroup is found.
Will raise an error if more than one layergroup with the same name is found.
'''
layergroups = self.get_layergroups(names=name, works... |
names and workspaces can be provided as a comma delimited strings or as arrays and are used for filtering. If no workspaces are provided will return all styles in the catalog ( global and workspace specific ). Will always return an array. | def get_styles(self, names=None, workspaces=None):
'''
names and workspaces can be provided as a comma delimited strings or as arrays, and are used for filtering.
If no workspaces are provided, will return all styles in the catalog (global and workspace specific).
Will always return an a... |
returns a single style object. Will return None if no style is found. Will raise an error if more than one style with the same name is found. | def get_style(self, name, workspace=None):
'''
returns a single style object.
Will return None if no style is found.
Will raise an error if more than one style with the same name is found.
'''
styles = self.get_styles(names=name, workspaces=workspace)
retur... |
Returns a list of workspaces in the catalog. If names is specified will only return workspaces that match. names can either be a comma delimited string or an array. Will return an empty list if no workspaces are found. | def get_workspaces(self, names=None):
'''
Returns a list of workspaces in the catalog.
If names is specified, will only return workspaces that match.
names can either be a comma delimited string or an array.
Will return an empty list if no workspaces are found.
''... |
returns a single workspace object. Will return None if no workspace is found. Will raise an error if more than one workspace with the same name is found. | def get_workspace(self, name):
'''
returns a single workspace object.
Will return None if no workspace is found.
Will raise an error if more than one workspace with the same name is found.
'''
workspaces = self.get_workspaces(names=name)
return self._return... |
Extract a metadata link tuple from an xml node | def md_link(node):
"""Extract a metadata link tuple from an xml node"""
mimetype = node.find("type")
mdtype = node.find("metadataType")
content = node.find("content")
if None in [mimetype, mdtype, content]:
return None
else:
return (mimetype.text, mdtype.text, content.text) |
Create a URL from a list of path segments and an optional dict of query parameters. | def build_url(base, seg, query=None):
"""
Create a URL from a list of path segments and an optional dict of query
parameters.
"""
def clean_segment(segment):
"""
Cleans the segment and encodes to UTF-8 if the segment is unicode.
"""
segment = segment.strip('/')
... |
GeoServer s REST API uses ZIP archives as containers for file formats such as Shapefile and WorldImage which include several boxcar files alongside the main data. In such archives GeoServer assumes that all of the relevant files will have the same base name and appropriate extensions and live in the root of the ZIP arc... | def prepare_upload_bundle(name, data):
"""GeoServer's REST API uses ZIP archives as containers for file formats such
as Shapefile and WorldImage which include several 'boxcar' files alongside
the main data. In such archives, GeoServer assumes that all of the relevant
files will have the same base name ... |
Extract metadata Dimension Info from an xml node | def md_dimension_info(name, node):
"""Extract metadata Dimension Info from an xml node"""
def _get_value(child_name):
return getattr(node.find(child_name), 'text', None)
resolution = _get_value('resolution')
defaultValue = node.find("defaultValue")
strategy = defaultValue.find("strategy") i... |
Extract metadata Dynamic Default Values from an xml node | def md_dynamic_default_values_info(name, node):
"""Extract metadata Dynamic Default Values from an xml node"""
configurations = node.find("configurations")
if configurations is not None:
configurations = []
for n in node.findall("configuration"):
dimension = n.find("dimension")
... |
Extract metadata JDBC Virtual Tables from an xml node | def md_jdbc_virtual_table(key, node):
"""Extract metadata JDBC Virtual Tables from an xml node"""
name = node.find("name")
sql = node.find("sql")
escapeSql = node.find("escapeSql")
escapeSql = escapeSql.text if escapeSql is not None else None
keyColumn = node.find("keyColumn")
keyColumn = ke... |
Extract metadata entries from an xml node | def md_entry(node):
"""Extract metadata entries from an xml node"""
key = None
value = None
if 'key' in node.attrib:
key = node.attrib['key']
else:
key = None
if key in ['time', 'elevation'] or key.startswith('custom_dimension'):
value = md_dimension_info(key, node.find(... |
if set get the value of resolution in milliseconds | def resolution_millis(self):
'''if set, get the value of resolution in milliseconds'''
if self.resolution is None or not isinstance(self.resolution, basestring):
return self.resolution
val, mult = self.resolution.split(' ')
return int(float(val) * self._multipier(mult) * ... |
if set get the value of resolution as <n > <period > s for example: 8 seconds | def resolution_str(self):
'''if set, get the value of resolution as "<n> <period>s", for example: "8 seconds"'''
if self.resolution is None or isinstance(self.resolution, basestring):
return self.resolution
seconds = self.resolution / 1000.
biggest = self._lookup[0]
f... |
Read resource information into self. _cache for cached access. | def _init(self):
"""Read resource information into self._cache, for cached access.
See DAVResource._init()
"""
# TODO: recalc self.path from <self._file_path>, to fix correct file system case
# On windows this would lead to correct URLs
self.provider._count_get_res... |
Return list of ( direct ) collection member names ( UTF - 8 byte strings ). | def get_member_list(self):
"""Return list of (direct) collection member names (UTF-8 byte strings).
See DAVResource.get_member_list()
"""
members = []
conn = self.provider._init_connection()
try:
tableName, primKey = self.provider._split_path(self.path)
... |
Open content as a stream for reading. | def get_content(self):
"""Open content as a stream for reading.
See DAVResource.get_content()
"""
filestream = compat.StringIO()
tableName, primKey = self.provider._split_path(self.path)
if primKey is not None:
conn = self.provider._init_connection()
... |
Return list of supported property names in Clark Notation. | def get_property_names(self, is_allprop):
"""Return list of supported property names in Clark Notation.
Return supported live and dead properties. (See also DAVProvider.get_property_names().)
In addition, all table field names are returned as properties.
"""
# Let default imple... |
Return the value of a property. | def get_property_value(self, name):
"""Return the value of a property.
The base implementation handles:
- ``{DAV:}lockdiscovery`` and ``{DAV:}supportedlock`` using the
associated lock manager.
- All other *live* properties (i.e. name starts with ``{DAV:}``) are
dele... |
Set or remove property value. | def set_property_value(self, name, value, dry_run=False):
"""Set or remove property value.
See DAVResource.set_property_value()
"""
raise DAVError(
HTTP_FORBIDDEN, err_condition=PRECONDITION_CODE_ProtectedProperty
) |
Return ( tableName primaryKey ) tuple for a request path. | def _split_path(self, path):
"""Return (tableName, primaryKey) tuple for a request path."""
if path.strip() in (None, "", "/"):
return (None, None)
tableName, primKey = util.save_split(path.strip("/"), "/", 1)
# _logger.debug("'%s' -> ('%s', '%s')" % (path, tableName, ... |
Return info dictionary for path. | def get_resource_inst(self, path, environ):
"""Return info dictionary for path.
See get_resource_inst()
"""
# TODO: calling exists() makes directory browsing VERY slow.
# At least compared to PyFileServer, which simply used string
# functions to get display_t... |
Return HTTP response string e. g. 204 - > ( 204 No Content ). The return string always includes descriptive text to satisfy Apache mod_dav. | def get_http_status_string(v):
"""Return HTTP response string, e.g. 204 -> ('204 No Content').
The return string always includes descriptive text, to satisfy Apache mod_dav.
`v`: status code or DAVError
"""
code = get_http_status_code(v)
try:
return ERROR_DESCRIPTIONS[code]
except K... |
Convert any non - DAVError exception to HTTP_INTERNAL_ERROR. | def as_DAVError(e):
"""Convert any non-DAVError exception to HTTP_INTERNAL_ERROR."""
if isinstance(e, DAVError):
return e
elif isinstance(e, Exception):
# traceback.print_exc()
return DAVError(HTTP_INTERNAL_ERROR, src_exception=e)
else:
return DAVError(HTTP_INTERNAL_ERROR... |
Return readable string. | def get_user_info(self):
"""Return readable string."""
if self.value in ERROR_DESCRIPTIONS:
s = "{}".format(ERROR_DESCRIPTIONS[self.value])
else:
s = "{}".format(self.value)
if self.context_info:
s += ": {}".format(self.context_info)
elif self... |
Return a tuple ( content - type response page ). | def get_response_page(self):
"""Return a tuple (content-type, response page)."""
# If it has pre- or post-condition: return as XML response
if self.err_condition:
return ("application/xml", compat.to_bytes(self.err_condition.as_string()))
# Else return as HTML
status... |
Change semantic of DELETE to remove resource tags. | def handle_delete(self):
"""Change semantic of DELETE to remove resource tags."""
# DELETE is only supported for the '/by_tag/' collection
if "/by_tag/" not in self.path:
raise DAVError(HTTP_FORBIDDEN)
# path must be '/by_tag/<tag>/<resname>'
catType, tag, _rest = uti... |
Change semantic of COPY to add resource tags. | def handle_copy(self, dest_path, depth_infinity):
"""Change semantic of COPY to add resource tags."""
# destPath must be '/by_tag/<tag>/<resname>'
if "/by_tag/" not in dest_path:
raise DAVError(HTTP_FORBIDDEN)
catType, tag, _rest = util.save_split(dest_path.strip("/"), "/", 2... |
Change semantic of MOVE to change resource tags. | def handle_move(self, dest_path):
"""Change semantic of MOVE to change resource tags."""
# path and destPath must be '/by_tag/<tag>/<resname>'
if "/by_tag/" not in self.path:
raise DAVError(HTTP_FORBIDDEN)
if "/by_tag/" not in dest_path:
raise DAVError(HTTP_FORBID... |
Return list of supported property names in Clark Notation. | def get_property_names(self, is_allprop):
"""Return list of supported property names in Clark Notation.
See DAVResource.get_property_names()
"""
# Let base class implementation add supported live and dead properties
propNameList = super(VirtualResource, self).get_property_names(... |
Return the value of a property. | def get_property_value(self, name):
"""Return the value of a property.
See get_property_value()
"""
# Supported custom live properties
if name == "{virtres:}key":
return self.data["key"]
elif name == "{virtres:}title":
return self.data["title"]
... |
Set or remove property value. | def set_property_value(self, name, value, dry_run=False):
"""Set or remove property value.
See DAVResource.set_property_value()
"""
if value is None:
# We can never remove properties
raise DAVError(HTTP_FORBIDDEN)
if name == "{virtres:}tags":
... |
Return _VirtualResource object for path. | def get_resource_inst(self, path, environ):
"""Return _VirtualResource object for path.
path is expected to be
categoryType/category/name/artifact
for example:
'by_tag/cool/My doc 2/info.html'
See DAVProvider.get_resource_inst()
"""
_logger.info(... |
Add a provider to the provider_map routing table. | def add_provider(self, share, provider, readonly=False):
"""Add a provider to the provider_map routing table."""
# Make sure share starts with, or is '/'
share = "/" + share.strip("/")
assert share not in self.provider_map
if compat.is_basestring(provider):
# Syntax:... |
Get the registered DAVProvider for a given path. | def resolve_provider(self, path):
"""Get the registered DAVProvider for a given path.
Returns:
tuple: (share, provider)
"""
# Find DAV provider that matches the share
share = None
lower_path = path.lower()
for r in self.sorted_share_list:
... |
Computes digest hash. | def compute_digest_response(
self, realm, user_name, method, uri, nonce, cnonce, qop, nc, environ
):
"""Computes digest hash.
Calculation of the A1 (HA1) part is delegated to the dc interface method
`digest_auth_user()`.
Args:
realm (str):
user_name ... |
Read a chunk of bytes from queue. | def read(self, size=0):
"""Read a chunk of bytes from queue.
size = 0: Read next chunk (arbitrary length)
> 0: Read one chunk of `size` bytes (or less if stream was closed)
< 0: Read all bytes as single chunk (i.e. blocks until stream is closed)
This method blocks unt... |
Put a chunk of bytes ( or an iterable ) to the queue. | def write(self, chunk):
"""Put a chunk of bytes (or an iterable) to the queue.
May block if max_size number of chunks is reached.
"""
if self.is_closed:
raise ValueError("Cannot write to closed object")
# print("FileLikeQueue.write(), n={}".format(len(chunk)))
... |
Read bytes from an iterator. | def read(self, size=None):
"""Read bytes from an iterator."""
while size is None or len(self.buffer) < size:
try:
self.buffer += next(self.data_stream)
except StopIteration:
break
sized_chunk = self.buffer[:size]
if size is None:
... |
Handle an error gracefully. May be overridden. | def handle_error(self, request, client_address):
"""Handle an error gracefully. May be overridden.
The default is to _logger.info a traceback and continue.
"""
ei = sys.exc_info()
e = ei[1]
# Suppress stack trace when client aborts connection disgracefully:
# 1... |
Stop serve_forever_stoppable (). | def stop_serve_forever(self):
"""Stop serve_forever_stoppable()."""
assert hasattr(
self, "stop_request"
), "serve_forever_stoppable() must be called before"
assert not self.stop_request, "stop_serve_forever() must only be called once"
# # Flag stop request
... |
Handle one request at a time until stop_serve_forever (). | def serve_forever_stoppable(self):
"""Handle one request at a time until stop_serve_forever().
http://code.activestate.com/recipes/336012/
"""
self.stop_request = False
self.stopped = False
while not self.stop_request:
self.handle_request()
# ... |
Return list of supported property names in Clark Notation. | def get_property_names(self, is_allprop):
"""Return list of supported property names in Clark Notation.
See DAVResource.get_property_names()
"""
# Let base class implementation add supported live and dead properties
propNameList = super(HgResource, self).get_property_names(is_al... |
Return the value of a property. | def get_property_value(self, name):
"""Return the value of a property.
See get_property_value()
"""
# Supported custom live properties
if name == "{hg:}branch":
return self.fctx.branch()
elif name == "{hg:}date":
# (secs, tz-ofs)
retur... |
Create and return an empty ( length - 0 ) resource as member of self. | def create_empty_resource(self, name):
"""Create and return an empty (length-0) resource as member of self.
See DAVResource.create_empty_resource()
"""
assert self.is_collection
self._check_write_access()
filepath = self._getFilePath(name)
f = open(filepath, "w")... |
Create a new collection as member of self. | def create_collection(self, name):
"""Create a new collection as member of self.
A dummy member is created, because Mercurial doesn't handle folders.
"""
assert self.is_collection
self._check_write_access()
collpath = self._getFilePath(name)
os.mkdir(collpath)
... |
Open content as a stream for reading. | def get_content(self):
"""Open content as a stream for reading.
See DAVResource.get_content()
"""
assert not self.is_collection
d = self.fctx.data()
return compat.StringIO(d) |
Open content as a stream for writing. | def begin_write(self, content_type=None):
"""Open content as a stream for writing.
See DAVResource.begin_write()
"""
assert not self.is_collection
self._check_write_access()
mode = "wb"
# GC issue 57: always store as binary
# if contentType and con... |
Called when PUT has finished writing. | def end_write(self, with_errors):
"""Called when PUT has finished writing.
See DAVResource.end_write()
"""
if not with_errors:
commands.add(self.provider.ui, self.provider.repo, self.localHgPath) |
Remove this resource ( recursive ). | def delete(self):
"""Remove this resource (recursive)."""
self._check_write_access()
filepath = self._getFilePath()
commands.remove(self.provider.ui, self.provider.repo, filepath, force=True) |
Handle a COPY request natively. | def handle_copy(self, dest_path, depth_infinity):
"""Handle a COPY request natively.
"""
destType, destHgPath = util.pop_path(dest_path)
destHgPath = destHgPath.strip("/")
ui = self.provider.ui
repo = self.provider.repo
_logger.info("handle_copy %s -> %s" % (self... |
Read log entries into a list of dictionaries. | def _get_log(self, limit=None):
"""Read log entries into a list of dictionaries."""
self.ui.pushbuffer()
commands.log(self.ui, self.repo, limit=limit, date=None, rev=None, user=None)
res = self.ui.popbuffer().strip()
logList = []
for logentry in res.split("\n\n"):
... |
Return a dictionary containing all files under source control. | def _get_repo_info(self, environ, rev, reload=False):
"""Return a dictionary containing all files under source control.
dirinfos:
Dictionary containing direct members for every collection.
{folderpath: (collectionlist, filelist), ...}
files:
Sorted list of al... |
Return HgResource object for path. | def get_resource_inst(self, path, environ):
"""Return HgResource object for path.
See DAVProvider.get_resource_inst()
"""
self._count_get_resource_inst += 1
# HG expects the resource paths without leading '/'
localHgPath = path.strip("/")
rev = None
cmd,... |
Return additional info dictionary for displaying ( optional ). | def get_display_info(self):
"""Return additional info dictionary for displaying (optional).
This information is not part of the DAV specification, but meant for use
by the dir browser middleware.
This default implementation returns ``{'type': '...'}``
"""
if self.is_col... |
Return preferred mapping for a resource mapping. | def get_preferred_path(self):
"""Return preferred mapping for a resource mapping.
Different URLs may map to the same resource, e.g.:
'/a/b' == '/A/b' == '/a/b/'
get_preferred_path() returns the same value for all these variants, e.g.:
'/a/b/' (assuming resource names c... |
Convert path to a URL that can be passed to XML responses. | def get_href(self):
"""Convert path to a URL that can be passed to XML responses.
Byte string, UTF-8 encoded, quoted.
See http://www.webdav.org/specs/rfc4918.html#rfc.section.8.3
We are using the path-absolute option. i.e. starting with '/'.
URI ; See section 3.2.1 of [RFC2068]... |
Return a list of direct members ( _DAVResource or derived objects ). | def get_member_list(self):
"""Return a list of direct members (_DAVResource or derived objects).
This default implementation calls self.get_member_names() and
self.get_member() for each of them.
A provider COULD overwrite this for performance reasons.
"""
if not self.is_... |
Return a list _DAVResource objects of a collection ( children grand - children... ). | def get_descendants(
self,
collections=True,
resources=True,
depth_first=False,
depth="infinity",
add_self=False,
):
"""Return a list _DAVResource objects of a collection (children,
grand-children, ...).
This default implementation calls self.... |
Return list of supported property names in Clark Notation. | def get_property_names(self, is_allprop):
"""Return list of supported property names in Clark Notation.
Note that 'allprop', despite its name, which remains for
backward-compatibility, does not return every property, but only dead
properties and the live properties defined in RFC4918.
... |
Return properties as list of 2 - tuples ( name value ). | def get_properties(self, mode, name_list=None):
"""Return properties as list of 2-tuples (name, value).
If mode is 'name', then None is returned for the value.
name
the property name in Clark notation.
value
may have different types, depending on the status:
... |
Return the value of a property. | def get_property_value(self, name):
"""Return the value of a property.
name:
the property name in Clark notation.
return value:
may have different types, depending on the status:
- string or unicode: for standard property values.
- lxml.etree.Ele... |
Set a property value or remove a property. | def set_property_value(self, name, value, dry_run=False):
"""Set a property value or remove a property.
value == None means 'remove property'.
Raise HTTP_FORBIDDEN if property is read-only, or not supported.
When dry_run is True, this function should raise errors, as in a real
... |
Remove all associated dead properties. | def remove_all_properties(self, recursive):
"""Remove all associated dead properties."""
if self.provider.prop_manager:
self.provider.prop_manager.remove_properties(
self.get_ref_url(), self.environ
) |
Return True if URI is locked. | def is_locked(self):
"""Return True, if URI is locked."""
if self.provider.lock_manager is None:
return False
return self.provider.lock_manager.is_url_locked(self.get_ref_url()) |
Return a _DAVResource object for the path ( None if not found ). | def resolve(self, script_name, path_info):
"""Return a _DAVResource object for the path (None, if not found).
`path_info`: is a URL relative to this object.
"""
if path_info in ("", "/"):
return self
assert path_info.startswith("/")
name, rest = util.pop_path... |
Set application location for this resource provider. | def set_share_path(self, share_path):
"""Set application location for this resource provider.
@param share_path: a UTF-8 encoded, unquoted byte string.
"""
# if isinstance(share_path, unicode):
# share_path = share_path.encode("utf8")
assert share_path == "" or share... |
Convert a refUrl to a path by stripping the share prefix. | def ref_url_to_path(self, ref_url):
"""Convert a refUrl to a path, by stripping the share prefix.
Used to calculate the <path> from a storage key by inverting get_ref_url().
"""
return "/" + compat.unquote(util.lstripstr(ref_url, self.share_path)).lstrip(
"/"
) |
Return True if path maps to an existing collection resource. | def is_collection(self, path, environ):
"""Return True, if path maps to an existing collection resource.
This method should only be used, if no other information is queried
for <path>. Otherwise a _DAVResource should be created first.
"""
res = self.get_resource_inst(path, envir... |
Convert XML string into etree. Element. | def string_to_xml(text):
"""Convert XML string into etree.Element."""
try:
return etree.XML(text)
except Exception:
# TODO:
# ExpatError: reference to invalid character number: line 1, column 62
# litmus fails, when xml is used instead of lxml
# 18. propget.............. |
Wrapper for etree. tostring that takes care of unsupported pretty_print option and prepends an encoding header. | def xml_to_bytes(element, pretty_print=False):
"""Wrapper for etree.tostring, that takes care of unsupported pretty_print
option and prepends an encoding header."""
if use_lxml:
xml = etree.tostring(
element, encoding="UTF-8", xml_declaration=True, pretty_print=pretty_print
)
... |
Wrapper for etree. SubElement that takes care of unsupported nsmap option. | def make_sub_element(parent, tag, nsmap=None):
"""Wrapper for etree.SubElement, that takes care of unsupported nsmap option."""
if use_lxml:
return etree.SubElement(parent, tag, nsmap=nsmap)
return etree.SubElement(parent, tag) |
Serialize etree. Element. | def element_content_as_string(element):
"""Serialize etree.Element.
Note: element may contain more than one child or only text (i.e. no child
at all). Therefore the resulting string may raise an exception, when
passed back to etree.XML().
"""
if len(element) == 0:
return ele... |
Convert path to absolute if not None. | def _get_checked_path(path, config, must_exist=True, allow_none=True):
"""Convert path to absolute if not None."""
if path in (None, ""):
if allow_none:
return None
raise ValueError("Invalid path {!r}".format(path))
# Evaluate path relative to the folder of the config file (if an... |
Parse command line options into a dictionary. | def _init_command_line_options():
"""Parse command line options into a dictionary."""
description = """\
Run a WEBDAV server to share file system folders.
Examples:
Share filesystem folder '/temp' for anonymous access (no config file used):
wsgidav --port=80 --host=0.0.0.0 --root=/temp --auth=anonymou... |
Read configuration file options into a dictionary. | def _read_config_file(config_file, verbose):
"""Read configuration file options into a dictionary."""
config_file = os.path.abspath(config_file)
if not os.path.exists(config_file):
raise RuntimeError("Couldn't open configuration file '{}'.".format(config_file))
if config_file.endswith(".json"... |
Setup configuration dictionary from default command line and configuration file. | def _init_config():
"""Setup configuration dictionary from default, command line and configuration file."""
cli_opts, parser = _init_command_line_options()
cli_verbose = cli_opts["verbose"]
# Set config defaults
config = copy.deepcopy(DEFAULT_CONFIG)
# Configuration file overrides defaults
... |
Run WsgiDAV using paste. httpserver if Paste is installed. | def _run_paste(app, config, mode):
"""Run WsgiDAV using paste.httpserver, if Paste is installed.
See http://pythonpaste.org/modules/httpserver.html for more options
"""
from paste import httpserver
version = "WsgiDAV/{} {} Python {}".format(
__version__, httpserver.WSGIHandler.server_versi... |
Run WsgiDAV using gevent if gevent is installed. | def _run_gevent(app, config, mode):
"""Run WsgiDAV using gevent if gevent is installed.
See
https://github.com/gevent/gevent/blob/master/src/gevent/pywsgi.py#L1356
https://github.com/gevent/gevent/blob/master/src/gevent/server.py#L38
for more options
"""
import gevent
import gevent... |
Run WsgiDAV using cherrypy. wsgiserver if CherryPy is installed. | def _run__cherrypy(app, config, mode):
"""Run WsgiDAV using cherrypy.wsgiserver if CherryPy is installed."""
assert mode == "cherrypy-wsgiserver"
try:
from cherrypy import wsgiserver
from cherrypy.wsgiserver.ssl_builtin import BuiltinSSLAdapter
_logger.warning("WARNING: cherrypy.ws... |
Run WsgiDAV using cheroot. server if Cheroot is installed. | def _run_cheroot(app, config, mode):
"""Run WsgiDAV using cheroot.server if Cheroot is installed."""
assert mode == "cheroot"
try:
from cheroot import server, wsgi
# from cheroot.ssl.builtin import BuiltinSSLAdapter
# import cheroot.ssl.pyopenssl
except ImportError:
... |
Run WsgiDAV using flup. server. fcgi if Flup is installed. | def _run_flup(app, config, mode):
"""Run WsgiDAV using flup.server.fcgi if Flup is installed."""
# http://trac.saddi.com/flup/wiki/FlupServers
if mode == "flup-fcgi":
from flup.server.fcgi import WSGIServer, __version__ as flupver
elif mode == "flup-fcgi-fork":
from flup.server.fcgi_fork... |
Run WsgiDAV using wsgiref. simple_server on Python 2. 5 +. | def _run_wsgiref(app, config, mode):
"""Run WsgiDAV using wsgiref.simple_server, on Python 2.5+."""
# http://www.python.org/doc/2.5.2/lib/module-wsgiref.html
from wsgiref.simple_server import make_server, software_version
version = "WsgiDAV/{} {}".format(__version__, software_version)
_logger.info(... |
Run WsgiDAV using ext_wsgiutils_server from the wsgidav package. | def _run_ext_wsgiutils(app, config, mode):
"""Run WsgiDAV using ext_wsgiutils_server from the wsgidav package."""
from wsgidav.server import ext_wsgiutils_server
_logger.info(
"Running WsgiDAV {} on wsgidav.ext_wsgiutils_server...".format(__version__)
)
_logger.warning(
"WARNING: Th... |
Wrapper to raise ( and log ) DAVError. | def _fail(self, value, context_info=None, src_exception=None, err_condition=None):
"""Wrapper to raise (and log) DAVError."""
util.fail(value, context_info, src_exception, err_condition) |
Send WSGI response ( single or multistatus ). | def _send_response(
self, environ, start_response, root_res, success_code, error_list
):
"""Send WSGI response (single or multistatus).
- If error_list is None or [], then <success_code> is send as response.
- If error_list contains a single error with a URL that matches root_res,
... |
Raise DAVError ( HTTP_LOCKED ) if res is locked. | def _check_write_permission(self, res, depth, environ):
"""Raise DAVError(HTTP_LOCKED), if res is locked.
If depth=='infinity', we also raise when child resources are locked.
"""
lockMan = self._davProvider.lock_manager
if lockMan is None or res is None:
return True
... |
Apply HTTP headers on <path > raising DAVError if conditions fail. | def _evaluate_if_headers(self, res, environ):
"""Apply HTTP headers on <path>, raising DAVError if conditions fail.
Add environ['wsgidav.conditions.if'] and environ['wsgidav.ifLockTokenList'].
Handle these headers:
- If-Match, If-Modified-Since, If-None-Match, If-Unmodified-Since:
... |
TODO: does not yet support If and If HTTP Conditions | def do_PROPFIND(self, environ, start_response):
"""
TODO: does not yet support If and If HTTP Conditions
@see http://www.webdav.org/specs/rfc4918.html#METHOD_PROPFIND
"""
path = environ["PATH_INFO"]
res = self._davProvider.get_resource_inst(path, environ)
# RFC: ... |
Handle PROPPATCH request to set or remove a property. | def do_PROPPATCH(self, environ, start_response):
"""Handle PROPPATCH request to set or remove a property.
@see http://www.webdav.org/specs/rfc4918.html#METHOD_PROPPATCH
"""
path = environ["PATH_INFO"]
res = self._davProvider.get_resource_inst(path, environ)
# Only accep... |
Handle MKCOL request to create a new collection. | def do_MKCOL(self, environ, start_response):
"""Handle MKCOL request to create a new collection.
@see http://www.webdav.org/specs/rfc4918.html#METHOD_MKCOL
"""
path = environ["PATH_INFO"]
provider = self._davProvider
# res = provider.get_resource_inst(path, enviro... |
Get the data from a chunked transfer. | def _stream_data_chunked(self, environ, block_size):
"""Get the data from a chunked transfer."""
# Chunked Transfer Coding
# http://www.servlets.com/rfcs/rfc2616-sec3.html#sec3.6.1
if "Darwin" in environ.get("HTTP_USER_AGENT", "") and environ.get(
"HTTP_X_EXPECTED_ENTITY_LEN... |
Get the data from a non - chunked transfer. | def _stream_data(self, environ, content_length, block_size):
"""Get the data from a non-chunked transfer."""
if content_length == 0:
# TODO: review this
# XP and Vista MiniRedir submit PUT with Content-Length 0,
# before LOCK and the real PUT. So we have to accept thi... |
If - Range If the entity is unchanged send me the part ( s ) that I am missing ; otherwise send me the entire new entity If - Range: 737060cd8c284d8af7ad3082f209582d | def _send_resource(self, environ, start_response, is_head_method):
"""
If-Range
If the entity is unchanged, send me the part(s) that I am missing;
otherwise, send me the entire new entity
If-Range: "737060cd8c284d8af7ad3082f209582d"
@see: http://www.w3.org/Pr... |
Return properties document for path. | def _find(self, url):
"""Return properties document for path."""
# Query the permanent view to find a url
vr = self.db.view("properties/by_url", key=url, include_docs=True)
_logger.debug("find(%r) returned %s" % (url, len(vr)))
assert len(vr) <= 1, "Found multiple matches for %r"... |
Return properties document for url and all children. | def _find_descendents(self, url):
"""Return properties document for url and all children."""
# Ad-hoc query for URL starting with a prefix
map_fun = """function(doc) {
var url = doc.url + "/";
if(doc.type === 'properties' && url.indexOf('%s') === 0) {
... |
Return the matching user_map entry ( falling back to default * if any ). | def _get_realm_entry(self, realm, user_name=None):
"""Return the matching user_map entry (falling back to default '*' if any)."""
realm_entry = self.user_map.get(realm)
if realm_entry is None:
realm_entry = self.user_map.get("*")
if user_name is None or realm_entry is None:
... |
Resolve a relative url to the appropriate realm name. | def get_domain_realm(self, path_info, environ):
"""Resolve a relative url to the appropriate realm name."""
realm = self._calc_realm_from_path_provider(path_info, environ)
return realm |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.