ZMailIn patch (index 'date' as DateTime object)
Hi Andy & all There I was, trying to select last week's mail messages from the ZMailInCatalog, when I realized that the 'date' index was a simple string. Here's a patch, adding a property 'datetime', which can be used as an index of type DateTime. Anything I'm missing here? In particular, I'm not sure I understand what 'sortableDate' is meant for. It's a string like this:: str('%04d%02d%02d%02d%02d%02d' % (dateTuple[0],dateTuple[1], dateTuple[2],dateTuple[3],dateTuple[4],dateTuple[5])) But it's still a string, and can't be used in comparisons with DateTimes. Why not just use 'datetime', also sortable? Regards, Jean Jordaan [jean@blommie ZMailIn]$ diff -u ./ZMailMessage.py ./ZMailMessage_hacked.py --- ./ZMailMessage.py Tue Mar 6 12:33:03 2001 +++ ./ZMailMessage_hacked.py Fri Nov 9 11:42:32 2001 @@ -61,6 +61,9 @@ self.subject = subject self.date = date self.sortableDate = self._convertToSortableDate(date) + # njj: index the date as a date. + import DateTime + self.datetime = DateTime.DateTime(date) self.to = to self.sender = sender self.replyto = replyto
Jean Jordaan wrote:
But it's still a string, and can't be used in comparisons with DateTimes. Why not just use 'datetime', also sortable?
DateTime objects are huge. There's this trade-off between cacheing up the presentation of dates, and their compactness for storage. In general in Zope, you want rendering speed and you don't care about the storage space. However, if you have a lot of dates, but you're only looking at a few of them at once, you'll want to optimise it the other way around. -- Steve Alexander Software Engineer Cat-Box limited
Hi Steve
Jean Jordaan wrote:
But it's still a string, and can't be used in comparisons with DateTimes. Why not just use 'datetime', also sortable?
DateTime objects are huge.
Hmm, OK, I'll keep that in mind .. For sorting my mails, though, I'll stick with the DateTimes. It would be cool if ZMailIn was more flexible as to which catalog it uses and what properties are indexed, without requiring one to hack the source .. I'll see if I can think of a way to make it so. Thanks for the answer, Jean
participants (2)
-
Jean Jordaan -
Steve Alexander