[CMF-checkins] SVN: CMF/trunk/CMF - reverted more
tools-as-utilities changes:
Yvo Schubbe
y.2007- at wcm-solutions.de
Fri Jun 22 04:52:12 EDT 2007
Log message for revision 76935:
- reverted more tools-as-utilities changes:
portal_calendar depends currently on self.REQUEST which is not available in utilities.
- added XXX comments to methods that need to be adjusted first
Changed:
U CMF/trunk/CMFCalendar/CalendarTool.py
U CMF/trunk/CMFCalendar/browser/calendartool.py
D CMF/trunk/CMFCalendar/profiles/default/componentregistry.xml
U CMF/trunk/CMFCalendar/skins/zpt_calendar/calendar_day_view.py
U CMF/trunk/CMFCalendar/skins/zpt_calendar/getMonthAndYear.py
U CMF/trunk/CMFDefault/skins/zpt_generic/getMainGlobals.py
-=-
Modified: CMF/trunk/CMFCalendar/CalendarTool.py
===================================================================
--- CMF/trunk/CMFCalendar/CalendarTool.py 2007-06-22 08:12:34 UTC (rev 76934)
+++ CMF/trunk/CMFCalendar/CalendarTool.py 2007-06-22 08:52:12 UTC (rev 76935)
@@ -24,7 +24,7 @@
from zope.interface import implements
from Products.PageTemplates.PageTemplateFile import PageTemplateFile
-from Products.CMFCore.utils import registerToolInterface
+from Products.CMFCore.utils import getToolByName
from Products.CMFCore.utils import UniqueObject
from interfaces import ICalendarTool
@@ -48,6 +48,7 @@
class CalendarTool (UniqueObject, SimpleItem):
+
""" A tool for encapsulating how calendars work and are displayed """
id = 'portal_calendar'
@@ -82,9 +83,11 @@
, use_session
, show_states=None
, firstweekday=None
- , REQUEST=None):
+ ):
""" Change the configuration of the calendar tool
"""
+ # XXX: this method violates the rules for tools/utilities:
+ # it depends on self.REQUEST
self.calendar_types = tuple(show_types)
self.use_session = bool(use_session)
@@ -102,8 +105,8 @@
# Do nothing with illegal values
pass
- if hasattr(REQUEST, 'RESPONSE'):
- REQUEST.RESPONSE.redirect('manage_configure')
+ if hasattr(self.REQUEST, 'RESPONSE'):
+ self.REQUEST.RESPONSE.redirect('manage_configure')
security.declarePrivate('_getCalendar')
def _getCalendar(self):
@@ -193,13 +196,16 @@
def catalog_getevents(self, year, month):
""" given a year and month return a list of days that have events
"""
+ # XXX: this method violates the rules for tools/utilities:
+ # it depends on a non-utility tool
year = int(year)
month = int(month)
last_day = self._getCalendar().monthrange(year, month)[1]
first_date = self.getBeginAndEndTimes(1, month, year)[0]
last_date = self.getBeginAndEndTimes(last_day, month, year)[1]
- query = self.portal_catalog(
+ ctool = getToolByName(self, 'portal_catalog')
+ query = ctool(
portal_type=self.getCalendarTypes(),
review_state=self.getCalendarStates(),
start={'query': last_date, 'range': 'max'},
@@ -280,7 +286,8 @@
B) End on this day OR
C) Start before this day AND end after this day
"""
- catalog = self.portal_catalog
+ # XXX: this method violates the rules for tools/utilities:
+ # it depends on a non-utility tool
day, month, year = ( int(thisDay.day())
, int(thisDay.month())
, int(thisDay.year())
@@ -292,21 +299,22 @@
after_midnight = DateTime(after_midnight_str)
# Get all events that Start on this day
- query = self.portal_catalog(
+ ctool = getToolByName(self, 'portal_catalog')
+ query = ctool(
portal_type=self.getCalendarTypes(),
review_state=self.getCalendarStates(),
start={'query': (first_date, last_date),
'range': 'minmax'} )
# Get all events that End on this day
- query += self.portal_catalog(
+ query += ctool(
portal_type=self.getCalendarTypes(),
review_state=self.getCalendarStates(),
end={'query': (after_midnight, last_date),
'range': 'minmax'} )
# Get all events that Start before this day AND End after this day
- query += self.portal_catalog(
+ query += ctool(
portal_type=self.getCalendarTypes(),
review_state=self.getCalendarStates(),
start={'query': first_date, 'range': 'max'},
@@ -368,10 +376,13 @@
start_date is expected to be a DateTime instance
"""
+ # XXX: this method violates the rules for tools/utilities:
+ # it depends on a non-utility tool
if start_date is None:
start_date = DateTime()
- query = self.portal_catalog(
+ ctool = getToolByName(self, 'portal_catalog')
+ query = ctool(
portal_type=self.getCalendarTypes(),
review_state=self.getCalendarStates(),
start={'query': start_date, 'range': 'min'},
@@ -382,6 +393,4 @@
results.sort(sort_by_date)
return results[0]
-
InitializeClass(CalendarTool)
-registerToolInterface('portal_calendar', ICalendarTool)
Modified: CMF/trunk/CMFCalendar/browser/calendartool.py
===================================================================
--- CMF/trunk/CMFCalendar/browser/calendartool.py 2007-06-22 08:12:34 UTC (rev 76934)
+++ CMF/trunk/CMFCalendar/browser/calendartool.py 2007-06-22 08:52:12 UTC (rev 76935)
@@ -16,15 +16,12 @@
"""
from DateTime.DateTime import DateTime
-from zope.component import getUtility
from Products.CMFDefault.browser.utils import decode
from Products.CMFDefault.browser.utils import memoize
from Products.CMFDefault.browser.utils import ViewBase
-from Products.CMFCalendar.interfaces import ICalendarTool
-
class CalendarView(ViewBase):
""" Helper class for calendar-related templates
@@ -95,7 +92,7 @@
def listItemInfos(self):
""" List item infos for all event catalog records for a specific day.
"""
- caltool = getUtility(ICalendarTool)
+ caltool = self._getTool('portal_calendar')
thisDay = self.viewDay()
items = [ {'title': item.Title,
@@ -115,7 +112,7 @@
def getMonthAndYear(self):
""" Retrieve month/year tuple
"""
- caltool = getUtility(ICalendarTool)
+ caltool = self._getTool('portal_calendar')
current = DateTime()
session = None
@@ -149,7 +146,7 @@
def getNextMonthLink(self, base_url, month, year):
""" Return URL for the next month link
"""
- caltool = getUtility(ICalendarTool)
+ caltool = self._getTool('portal_calendar')
nextMonthTime = caltool.getNextMonth(month, year)
x = '%s?month:int=%d&year:int=%d' % ( base_url
@@ -162,7 +159,7 @@
def getPreviousMonthLink(self, base_url, month, year):
""" Return URL for the previous month link
"""
- caltool = getUtility(ICalendarTool)
+ caltool = self._getTool('portal_calendar')
prevMonthTime = caltool.getPreviousMonth(month, year)
x = '%s?month:int=%d&year:int=%d' % ( base_url
Deleted: CMF/trunk/CMFCalendar/profiles/default/componentregistry.xml
===================================================================
--- CMF/trunk/CMFCalendar/profiles/default/componentregistry.xml 2007-06-22 08:12:34 UTC (rev 76934)
+++ CMF/trunk/CMFCalendar/profiles/default/componentregistry.xml 2007-06-22 08:52:12 UTC (rev 76935)
@@ -1,9 +0,0 @@
-<?xml version="1.0"?>
-<componentregistry>
- <adapters/>
- <utilities>
- <utility
- interface="Products.CMFCalendar.interfaces.ICalendarTool"
- object="/portal_calendar"/>
- </utilities>
-</componentregistry>
Modified: CMF/trunk/CMFCalendar/skins/zpt_calendar/calendar_day_view.py
===================================================================
--- CMF/trunk/CMFCalendar/skins/zpt_calendar/calendar_day_view.py 2007-06-22 08:12:34 UTC (rev 76934)
+++ CMF/trunk/CMFCalendar/skins/zpt_calendar/calendar_day_view.py 2007-06-22 08:52:12 UTC (rev 76935)
@@ -1,9 +1,9 @@
##parameters=
##
-from Products.CMFCore.utils import getToolByInterfaceName
+from Products.CMFCore.utils import getToolByName
from Products.CMFDefault.utils import decode
-caltool = getToolByInterfaceName('Products.CMFCalendar.interfaces.ICalendarTool')
+caltool = getToolByName(script, 'portal_calendar')
options = {}
base_url = script.absolute_url()
Modified: CMF/trunk/CMFCalendar/skins/zpt_calendar/getMonthAndYear.py
===================================================================
--- CMF/trunk/CMFCalendar/skins/zpt_calendar/getMonthAndYear.py 2007-06-22 08:12:34 UTC (rev 76934)
+++ CMF/trunk/CMFCalendar/skins/zpt_calendar/getMonthAndYear.py 2007-06-22 08:52:12 UTC (rev 76935)
@@ -1,9 +1,9 @@
# Get the year and month that the calendar should display.
-from Products.CMFCore.utils import getToolByInterfaceName
+from Products.CMFCore.utils import getToolByName
-caltool = getToolByInterfaceName('Products.CMFCalendar.interfaces.ICalendarTool')
+caltool = getToolByName(script, 'portal_calendar')
current = DateTime()
session = None
Modified: CMF/trunk/CMFDefault/skins/zpt_generic/getMainGlobals.py
===================================================================
--- CMF/trunk/CMFDefault/skins/zpt_generic/getMainGlobals.py 2007-06-22 08:12:34 UTC (rev 76934)
+++ CMF/trunk/CMFDefault/skins/zpt_generic/getMainGlobals.py 2007-06-22 08:52:12 UTC (rev 76935)
@@ -6,8 +6,7 @@
from Products.CMFDefault.utils import getBrowserCharset
atool = getToolByName(script, 'portal_actions')
-caltool_iface = 'Products.CMFCalendar.interfaces.ICalendarTool'
-caltool = getToolByInterfaceName(caltool_iface, None)
+caltool = getToolByName(script, 'portal_calendar', None)
mtool = getToolByInterfaceName('Products.CMFCore.interfaces.IMembershipTool')
ptool = getToolByInterfaceName('Products.CMFCore.interfaces.IPropertiesTool')
utool = getToolByName(script, 'portal_url')
More information about the CMF-checkins
mailing list