-
Notifications
You must be signed in to change notification settings - Fork 108
Description
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()