Example #1
0
    def _create(self, name, id=None):
        """
        Create a new calendar with display name `name` in `parent`.
        """
        path = None
        if id is None:
            id = str(uuid.uuid1())

        name = dav.DisplayName(name)
        cal = cdav.CalendarCollection()
        coll = dav.Collection() + cal
        type = dav.ResourceType() + coll

        prop = dav.Prop() + [type, name]
        set = dav.Set() + prop

        mkcol = dav.Mkcol() + set

        q = etree.tostring(mkcol.xmlelement(), encoding="utf-8", xml_declaration=True)
        path = url.join(self.parent.url.path, id)

        r = self.client.mkcol(path, q)
        if r.status == 201:
            # XXX Should we use self.canonical_url ?
            path = url.make(self.parent.url, path)
        else:
            raise error.MkcolError(r.raw)

        return (id, path)
Example #2
0
    def teardown(self):
        p = url.make(self.principal.url)
        path = url.join(p, testcal_id)

        cal = Calendar(self.caldav, name="Yep", parent = self.principal,
                       url = path)
        cal.delete()
Example #3
0
def create_calendar(client, parent, name, id=None):
    """
    Create a new calendar with display name `name` in `parent`.
    """
    path = None
    if id is None:
        id = str(uuid.uuid1())

    name = dav.DisplayName(name)
    cal = cdav.CalendarCollection()
    coll = dav.Collection() + cal
    type = dav.ResourceType() + coll

    prop = dav.Prop() + [type, name]
    set = dav.Set() + prop

    mkcol = dav.Mkcol() + set

    q = etree.tostring(mkcol.xmlelement(),
                       encoding="utf-8",
                       xml_declaration=True)
    path = url.join(parent.url.path, id)

    r = client.mkcol(path, q)
    if r.status == 201:
        path = url.make(parent.url, path)
    else:
        raise error.MkcolError(r.raw)

    return (id, path)
Example #4
0
    def teardown(self):
        p = url.make(self.principal.url)
        path = url.join(p, testcal_id)

        cal = Calendar(self.caldav,
                       name="Yep",
                       parent=self.principal,
                       url=path)
        cal.delete()
Example #5
0
    def _create(self, data, id=None, path=None):
        if id is None:
            id = str(uuid.uuid1())
        if path is None:
            path = url.join(self.parent.url.path, id + ".ics")

        r = self.client.put(path, data, {"Content-Type": 'text/calendar; charset="utf-8"'})
        if r.status == 204 or r.status == 201:
            # XXX Should we use self.canonical_url ?
            path = url.make(self.parent.url, path)
        else:
            raise error.PutError(r.raw)

        return (id, path)
Example #6
0
def create_event(client, calendar, data, id=None):
    path = None
    if id is None:
        id = str(uuid.uuid1())

    path = url.join(calendar.url.path, id + ".ics")
    r = client.put(path, data,
                   {"Content-Type": "text/calendar; charset=\"utf-8\""})
    if r.status == 204 or r.status == 201:
        path = url.make(calendar.url, path)
    else:
        raise error.PutError(r.raw)

    return (id, path)