[CalendarServer-dev] PATCH - Fixing #207

Peter Mogensen apm at one.com
Fri Aug 22 08:14:53 PDT 2008

Wilfredo Sánchez Vega wrote:
>   This sounds sane to me.  Cyrus may comment further, since he wrote the 
> first pass at this.


I have a working patch attached at 

I haven't found any code style guidelines, so please comment.

It can be done better. There were a few things to consider. Like:

* I replaces the expression generation functions in calendarquery.py
   with a class to hold state about the filter expression found during
   generation. (like: Do we have a timerange with an end date).
   An alternative would be to traverse expression hierarchy after
   generation to look for timerange expressions.
   I think an expression generator object is more fleksible.

* I have just returned a tuple (SQL-qualifiers, enddate) from
   This should probably be an object to allow for other future condition,
   but I couldn't think of any, so it became a simple tuple.

* I removed index.searchValid() and replaced index.search with 2
   index.indexedSearch(filter)   # throwing an IndexedSearchException

   Code using the index for search should now be prepared to handle an
   IndexedSearchExcetion in case an indexed search is not possible and
   call bruteforceSearch() them self.
   I think this is cleaner and it saves the duplication of parsing the
   filter expression which searchValid() did.

* I've been lazy and just removed resources needing expansion from the
   index and re-adding them with a longer expansion.
   It would probably be better to just add the missing TIMESPAN entries.
   ... next version.

Please comment,

More information about the calendarserver-dev mailing list