python-caldav / caldav

Apache License 2.0
330 stars 98 forks source link

Search event with summary #434

Open paramazo opened 2 months ago

paramazo commented 2 months ago

As described in this commit, i try to search for event with a specific summary. This seems not to work as expected, the attribute gets ignored and all events are fetched.

            events_fetched = calendar.search(
                start=dtstart,
                end=dtend,
                summary="my event 1",
                event=True,
                expand=True)

As a workaround i use search and then i have to use a for loop to check if the summary was found.

            events_fetched = calendar.search(
                start=dtstart,
                end=dtend,
                event=True,
                expand=True)

            split_event = False
            for event in events_fetched:
                summary = event.icalendar_component.get("summary")
                if "my event 1" in summary:
                    split_event = True
tobixen commented 2 months ago

It's a server compatibility problem, but I think the workaround should be cheap and harmless and can be added to the CalDAV-library (for all servers ... I do have a long term plan to address server compatibility issues by giving a hint on what kind of server one connects to when creating the client object, then such workarounds would be triggered only on the servers that needs it). Would you care to create a merge request?

paramazo commented 2 months ago

Sorry, i dont know how to implement it into the CalDAV-library. For me its fine to use the workaround in my script. Maybe you can find a more elegant solution to support summary filtering on search function.

tobixen commented 2 months ago

Ok, I will make a fix for this ... at some point in the future, I'm currently a bit overloaded. Should probably make a generic fix for all the text attributes and not only the summary. And it's needed with test code as well.

tobixen commented 1 month ago

I will make a proper and general workaround, and do client-side filtering together with #402