python-caldav / caldav

Apache License 2.0
319 stars 95 forks source link

Search event with summary #434

Open paramazo opened 1 week ago

paramazo commented 1 week 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 1 week 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 1 week 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 1 week 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.