How to use the xandikos.webdav function in xandikos

To help you get started, we’ve selected a few xandikos examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jelmer / xandikos / xandikos / access.py View on Github external
"""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):
github jelmer / xandikos / xandikos / timezones.py View on Github external
# 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
github jelmer / xandikos / xandikos / infit.py View on Github external
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
github jelmer / xandikos / xandikos / infit.py View on Github external
# 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'
github jelmer / xandikos / xandikos / infit.py View on Github external
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)

github jelmer / xandikos / xandikos / davcommon.py View on Github external
# 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):