""" returns a sorted list of calendar events """ # Copyright © 2004 Saugus.net, Inc. # All Rights Reserved. # This software is subject to the provisions of the Zope Public License, # Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution. # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # FOR A PARTICULAR PURPOSE. from DateTime import DateTime earlyMornin=DateTime().earliestTime() year,month=context.getMonthAndYear() prevMonthTime=context.portal_calendar.getPreviousMonth(month,year) nextMonthTime=context.portal_calendar.getNextMonth(month,year) prevMonthMonth,prevMonthYear=prevMonthTime.month(),prevMonthTime.year() dayNames={0:'Monday',1:'Tuesday',2:'Wednesday',3:'Thursday',4:'Friday',5:'Saturday',6:'Sunday'} events=[] eventDict={} eventCatEntries=context.portal_catalog(portal_type=context.portal_calendar.getCalendarTypes(), review_state='published',Subject={'query':subjectStr}, start=(earlyMornin,earlyMornin+90), start_usage='range:min:max', sort_on='start') if eventCatEntries: for eventCatEntry in eventCatEntries: key=eventCatEntry.start.Date() if eventDict.has_key(key): eventDict[key].append(eventCatEntry.getObject()) else: eventDict[key]=[eventCatEntry.getObject()] eventTuples=eventDict.items() eventTuples.sort() for eventTuple in eventTuples: date=DateTime(eventTuple[0]) key="%s, %s %i%s"%(date.Day(),date.Month(),date.day(),context.daySuffix(date.day())) events.append((key,eventTuple[1])) return events