Skip to content

Rethink the new search API #590

@tobixen

Description

@tobixen

Old style searches was done by using a simple method call, like calendar.search(from=..., to=..., summary=..., ....). This is easy to use, but the search parameter approach gives quite some limitations, it's not possible to do complex filtering like this.

In 2.2 a new possible approach was made:

from caldav.search import CalDAVSearcher
searcher = CalDAVSearcher(from=..., ...)
searcher.add_property_filter(...)
searcher.add_sort_key(...)
searcher.search(calendar)

This hasn't been very well thought-through. I designed it, and I'm quite happy with the icalendar-search package I made while working at it - but to be honest - I don't like this usage pattern at all!

When looking through #92, one of the design thoughts there was to avoid the user having to construct objects directly from the class constructor. searcher = CalDAVSearcher(...) is a blatant breach of this idea, and probably one of the reasons why I don't like the pattern above.

More thought should be made around this. Perhaps the better idea is something like this:

searcher = calendar.searcher(...)
searcher.add_property_filter(...)
results = searcher.search()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions