Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
"""current-user-privilege-set property
See http://www.webdav.org/specs/rfc3744.html, section 3.7
"""
name = '{DAV:}current-user-privilege-set'
in_allprops = False
live = True
def get_value(self, href, resource, el, environ):
privilege = ET.SubElement(el, '{DAV:}privilege')
# TODO(jelmer): Use something other than all
ET.SubElement(privilege, '{DAV:}all')
class OwnerProperty(webdav.Property):
"""owner property.
See http://www.webdav.org/specs/rfc3744.html, section 5.1
"""
name = '{DAV:}owner'
in_allprops = False
live = True
def get_value(self, base_href, resource, el, environ):
owner_href = resource.get_owner()
if owner_href is not None:
el.append(webdav.create_href(owner_href, base_href=base_href))
class GroupMembershipProperty(webdav.Property):
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
# MA 02110-1301, USA.
"""Timezone handling.
See http://www.webdav.org/specs/rfc7809.html
"""
from xandikos import webdav
class TimezoneServiceSetProperty(webdav.Property):
"""timezone-service-set property
See http://www.webdav.org/specs/rfc7809.html, section 5.1
"""
name = '{DAV:}timezone-service-set'
# Should be set on CalDAV calendar home collection resources,
# but Xandikos doesn't have a separate resource type for those.
resource_type = webdav.COLLECTION_RESOURCE_TYPE
in_allprops = False
live = True
def __init__(self, timezone_services):
super(TimezoneServiceSetProperty, self).__init__()
self._timezone_services = timezone_services
async def get_value(self, href, resource, el, environ):
el.text = resource.get_addressbook_color()
def set_value(self, href, resource, el):
resource.set_addressbook_color(el.text)
class HeaderValueProperty(webdav.Property):
"""Provides the header-value property.
This behaves similar to the hrefLabel setting in caldavzap/carddavmate.
"""
name = '{http://inf-it.com/ns/dav/}headervalue'
resource_type = webdav.COLLECTION_RESOURCE_TYPE
in_allprops = False
live = False
async def get_value(self, href, resource, el, environ):
el.text = resource.get_headervalue()
def set_value(self, href, resource, el):
# TODO
raise NotImplementedError
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
# MA 02110-1301, USA.
"""Inf-It properties.
"""
from xandikos import webdav, carddav
class SettingsProperty(webdav.Property):
"""settings propety.
JSON settings.
"""
name = '{http://inf-it.com/ns/dav/}settings'
resource_type = webdav.PRINCIPAL_RESOURCE_TYPE
live = False
async def get_value(self, href, resource, el, environ):
el.text = resource.get_infit_settings()
def set_value(self, href, resource, el):
resource.set_infit_settings(el.text)
class AddressbookColorProperty(webdav.Property):
"""Provides the addressbook-color property.
Contains a RRGGBB code, similar to calendar-color.
"""
name = '{http://inf-it.com/ns/ab/}addressbook-color'
JSON settings.
"""
name = '{http://inf-it.com/ns/dav/}settings'
resource_type = webdav.PRINCIPAL_RESOURCE_TYPE
live = False
async def get_value(self, href, resource, el, environ):
el.text = resource.get_infit_settings()
def set_value(self, href, resource, el):
resource.set_infit_settings(el.text)
class AddressbookColorProperty(webdav.Property):
"""Provides the addressbook-color property.
Contains a RRGGBB code, similar to calendar-color.
"""
name = '{http://inf-it.com/ns/ab/}addressbook-color'
resource_type = carddav.ADDRESSBOOK_RESOURCE_TYPE
in_allprops = False
async def get_value(self, href, resource, el, environ):
el.text = resource.get_addressbook_color()
def set_value(self, href, resource, el):
resource.set_addressbook_color(el.text)
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
# MA 02110-1301, USA.
"""Common functions for DAV implementations."""
from xandikos import webdav
ET = webdav.ET
class SubbedProperty(webdav.Property):
"""Property with sub-components that can be queried."""
async def get_value_ext(self, href, resource, el, environ, requested):
"""Get the value of a data property.
:param href: Resource href
:param resource: Resource to get value for
:param el: Element to fill in
:param environ: WSGI environ dict
:param requested: Requested property (including subelements)
"""
raise NotImplementedError(self.get_value_ext)
async def get_properties_with_data(data_property, href, resource, properties,
environ, requested):