Am 27.11.2006 um 14:14 schrieb Charlie Clark:

He isn't my friend - my brain has difficulties with the command line %-) but I asked the question after reading the source. I'm working on my own script to do the work but think it might be a good idea to have it in the tool itself. BTW. it's the first time I've come across getToolByName.

This is method I've come up with:

    def getNextEvent(self):
        """ Get the next event from the calendar"""
        today = DateTime()
        print today
        query = self.portal_catalog(
                    start={'query': today, 'range': 'max'},

def sort_function(x,y): # this should be a utility method for the class # as indeed should the check for uniqueness
            z = cmp(x.start,y.start)
            if not z:
                return cmp(x.end,y.end)
            return z

        rids = []
        results = []
        for result in query:
            if not result.getRID in rids:
        if results:
            return results[0]
        return None # probably unnecessary

I've also written a simple next_event_view script and next_event_view_template I'd write a test for this but I've never written a test so it might go horribly wrong! ;-)

If you wish I'd be happy to submit this although I think the changes for unique results and sorting should also be reflected.

Charlie Clark
Helmholtzstr. 20
D- 40215
Tel: +49-211-938-5360
GSM: +49-178-782-6226

Zope-CMF maillist  -

See for bug reports and feature requests

Reply via email to