[Calypso] [PATCH 3/3] Add is-addressbook and is-calendar settings.

Guido G├╝nther agx at sigxcpu.org
Sat Apr 9 15:46:34 PDT 2016


On Sat, Apr 09, 2016 at 06:09:43PM +0000, Jelmer Vernooij wrote:
> From: Jelmer Vernoo─│ <jelmer at jelmer.uk>
> 
> This is necessary acal (for which every collection is either an address
> book or a calendar).
> 
> Both settings default to True (current behaviour).

LGTM and passes our minimal caldav-tester suite.
 -- Guido

> 
> Based on patches by chrysn.
> ---
>  README              | 12 ++++++++++--
>  calypso/webdav.py   | 14 ++++++++++++++
>  calypso/xmlutils.py | 10 ++++++----
>  collection-config   |  7 +++++++
>  4 files changed, 37 insertions(+), 6 deletions(-)
> 
> diff --git a/README b/README
> index 11a8c23..c26fd6f 100644
> --- a/README
> +++ b/README
> @@ -47,13 +47,21 @@ To add a new database:
>  $ mkdir -p ~/.config/calypso/calendars/private/test
>  $ cd ~/.config/calypso/calendars/private/test
>  $ git init
> -$ git commit --allow-empty -m'initialize new calendar'
> +$ cat > .calypso-collection << EOF
> +[collection]
> +is-calendar = 1
> +EOF
> +$ git add .calypso-collection
> +$ git commit -m'initialize new calendar'
>  
>  The new calendar should now be visible as https://USER:PASSWORD@localhost:5233/private/test.
>  
>  You can add files to the directory at any time; calypso will check the
>  directory mtime at each operation and update its internal state from
> -that on disk automatically when the directory changes.  Importing files
> +that on disk automatically when the directory changes.
> +
> +Importing files
> +---------------
>  
>  Given a set of files with VCALENDAR or VCARD entries, you can import them with:
>  
> diff --git a/calypso/webdav.py b/calypso/webdav.py
> index 4ed095c..186bc00 100644
> --- a/calypso/webdav.py
> +++ b/calypso/webdav.py
> @@ -612,3 +612,17 @@ class Collection(object):
>      @property
>      def length(self):
>          return "%d" % len(self.text)
> +
> +    @property
> +    def is_addressbook(self):
> +        try:
> +            return self.metadata.getboolean('collection', 'is-addressbook')
> +        except (ConfigParser.NoSectionError, ConfigParser.NoOptionError, ValueError):
> +            return True
> +
> +    @property
> +    def is_calendar(self):
> +        try:
> +            return self.metadata.getboolean('collection', 'is-calendar')
> +        except (ConfigParser.NoSectionError, ConfigParser.NoOptionError, ValueError):
> +            return True
> diff --git a/calypso/xmlutils.py b/calypso/xmlutils.py
> index e705588..7c0f430 100644
> --- a/calypso/xmlutils.py
> +++ b/calypso/xmlutils.py
> @@ -159,10 +159,12 @@ def propfind(path, xml_request, collection, depth, context):
>          for tag in props:
>              element = ET.Element(tag)
>              if tag == _tag("D", "resourcetype") and is_collection:
> -                tag = ET.Element(_tag("C", "calendar"))
> -                element.append(tag)
> -                tag = ET.Element(_tag("A", "addressbook"))
> -                element.append(tag)
> +                if collection.is_calendar:
> +                    tag = ET.Element(_tag("C", "calendar"))
> +                    element.append(tag)
> +                if collection.is_addressbook:
> +                    tag = ET.Element(_tag("A", "addressbook"))
> +                    element.append(tag)
>                  tag = ET.Element(_tag("D", "collection"))
>                  element.append(tag)
>              elif tag == _tag("D", "owner"):
> diff --git a/collection-config b/collection-config
> index 4ce34a4..c1a2e24 100644
> --- a/collection-config
> +++ b/collection-config
> @@ -11,4 +11,11 @@ displayname = My Calendar
>  # WebDAV properties. Defaults to the collection's path.
>  description = Collection of all my personal dates.
>  
> +# Advertise this collection as a calendar. If this setting is absent,
> +# it defaults to True.
> +is-calendar = 1
> +# Advertise this collection as an address book. Behaves in analogy to
> +# is-calendar.
> +is-addressbook = 0
> +
>  # vim:ft=cfg
> -- 
> 2.8.0.rc3
> 
> _______________________________________________
> Calypso mailing list
> Calypso at keithp.com
> http://keithp.com/mailman/listinfo/calypso


More information about the Calypso mailing list