Back to index

plone3  3.1.7
CalendarTool.py
Go to the documentation of this file.
00001 from Products.CMFCalendar.CalendarTool import CalendarTool as BaseTool
00002 from Products.CMFPlone import ToolNames
00003 from AccessControl import ClassSecurityInfo
00004 from Globals import InitializeClass
00005 from Products.CMFPlone.PloneBaseTool import PloneBaseTool
00006 
00007 class CalendarTool(PloneBaseTool, BaseTool):
00008 
00009     meta_type = ToolNames.CalendarTool
00010     security = ClassSecurityInfo()
00011     toolicon = 'skins/plone_images/event_icon.gif'
00012 
00013     __implements__ = (PloneBaseTool.__implements__, BaseTool.__implements__, )
00014 
00015     firstweekday = 0 # 0 is Monday
00016 
00017     security.declarePublic('getDayNumbers')
00018     def getDayNumbers(self):
00019         """ Returns a list of daynumbers with the correct start day first.
00020 
00021         >>> import calendar
00022 
00023         CMFCalendar / Python's calendar module and the translation service tool
00024         use different values for the first day of week. To get the right
00025         localized day names with the translation service tool we need a method
00026         to return the days in the order used by CMFCalendar.
00027 
00028         >>> fwday = (calendar.firstweekday()+1) % 7
00029 
00030         >>> ctool = CalendarTool()
00031 
00032         >>> ctool.getDayNumbers()[0] == fwday
00033         True
00034         """
00035         firstweekday = self._getCalendar().firstweekday()+1
00036         return [i%7 for i in range(firstweekday, firstweekday + 7)]
00037 
00038 CalendarTool.__doc__ = BaseTool.__doc__
00039 
00040 InitializeClass(CalendarTool)