#7 — getPreviousViewUrl fails when previous month has less days

by Clayton Parker last modified Feb 21, 2009 09:11 PM
State Unconfirmed
Version:
Area Functionality
Issue type Bug
Severity Medium
Submitted by Clayton Parker
Submitted on Jul 31, 2008
Responsible
Target release:
The problem with the getPreviousViewUrl (and the getNextViewUrl) is that it expects the previous month to have the same amount of days as the current month. When I go to a calendar on July, 31 it is expecting there to be a June, 31. Here is what gets called:

return self._get_view_url_for_date(date(year, month, day))
return self._get_view_url_for_date(date(2008, 6, 31))

Which results in a ValueError since June only has 30 days. Oh and don't forget about leap year :)

Software stack:

python 2.4.5
Zope 2.10.5
Plone 3.0.6
dateable.chronos 0.3 (testing on trunk)

Here is the traceback:

2008-07-31 15:28:33 ERROR Zope.SiteErrorLog http://localhost:51056/project/mastercalendar/month.html
Traceback (innermost last):
  Module ZPublisher.Publish, line 119, in publish
  Module ZPublisher.mapply, line 88, in mapply
  Module Products.PDBDebugMode.pdbzope.runcall, line 60, in pdb_runcall
  Module ZPublisher.Publish, line 42, in call_object
  Module Products.Five.browser.metaconfigure, line 417, in __call__
  Module Shared.DC.Scripts.Bindings, line 313, in __call__
  Module Shared.DC.Scripts.Bindings, line 350, in _bindAndExec
  Module Products.PageTemplates.PageTemplateFile, line 129, in _exec
  Module Products.PTProfiler.ProfilerPatch, line 83, in __patched_render__
  Module Products.PageTemplates.PageTemplate, line 89, in pt_render
  Module zope.pagetemplate.pagetemplate, line 117, in pt_render
  Module zope.tal.talinterpreter, line 271, in __call__
  Module zope.tal.talinterpreter, line 346, in interpret
  Module zope.tal.talinterpreter, line 891, in do_useMacro
  Module zope.tal.talinterpreter, line 346, in interpret
  Module zope.tal.talinterpreter, line 536, in do_optTag_tal
  Module zope.tal.talinterpreter, line 521, in do_optTag
  Module zope.tal.talinterpreter, line 516, in no_tag
  Module zope.tal.talinterpreter, line 346, in interpret
  Module zope.tal.talinterpreter, line 891, in do_useMacro
  Module zope.tal.talinterpreter, line 346, in interpret
  Module zope.tal.talinterpreter, line 536, in do_optTag_tal
  Module zope.tal.talinterpreter, line 521, in do_optTag
  Module zope.tal.talinterpreter, line 516, in no_tag
  Module zope.tal.talinterpreter, line 346, in interpret
  Module zope.tal.talinterpreter, line 957, in do_defineSlot
  Module zope.tal.talinterpreter, line 346, in interpret
  Module zope.tal.talinterpreter, line 536, in do_optTag_tal
  Module zope.tal.talinterpreter, line 521, in do_optTag
  Module zope.tal.talinterpreter, line 516, in no_tag
  Module zope.tal.talinterpreter, line 346, in interpret
  Module zope.tal.talinterpreter, line 861, in do_defineMacro
  Module zope.tal.talinterpreter, line 346, in interpret
  Module zope.tal.talinterpreter, line 949, in do_defineSlot
  Module zope.tal.talinterpreter, line 346, in interpret
  Module zope.tal.talinterpreter, line 536, in do_optTag_tal
  Module zope.tal.talinterpreter, line 521, in do_optTag
  Module zope.tal.talinterpreter, line 516, in no_tag
  Module zope.tal.talinterpreter, line 346, in interpret
  Module zope.tal.talinterpreter, line 949, in do_defineSlot
  Module zope.tal.talinterpreter, line 346, in interpret
  Module zope.tal.talinterpreter, line 536, in do_optTag_tal
  Module zope.tal.talinterpreter, line 521, in do_optTag
  Module zope.tal.talinterpreter, line 516, in no_tag
  Module zope.tal.talinterpreter, line 346, in interpret
  Module zope.tal.talinterpreter, line 408, in do_startTag
  Module zope.tal.talinterpreter, line 485, in attrAction_tal
  Module Products.PageTemplates.Expressions, line 228, in evaluateText
  Module zope.tales.tales, line 696, in evaluate
   - URL: index
   - Line 36, Column 20
   - Expression: <PathExpr standard:'view/getPreviousViewUrl'>
   - Names:
      {'container': <ATTopic at /project/mastercalendar>,
       'context': <ATTopic at /project/mastercalendar>,
       'default': <object object at 0x2a528>,
       'here': <ATTopic at /project/mastercalendar>,
       'loop': {},
       'nothing': None,
       'options': {'args': (<Products.Five.metaclass.SimpleViewClass from /path/to/project/project-buildout/src/dateable.chronos/dateable/chronos/browser/month.pt object at 0x728f510>,)},
       'repeat': <Products.PageTemplates.Expressions.SafeMapping object at 0x72a8530>,
       'request': <HTTPRequest, URL=http://localhost:51056/[…]/month.html>,
       'root': <Application at >,
       'template': <ImplicitAcquirerWrapper object at 0x728ff10>,
       'traverse_subpath': [],
       'user': <PropertiedUser 'admin'>,
       'view': <Products.Five.metaclass.SimpleViewClass from /path/to/project/project-buildout/src/dateable.chronos/dateable/chronos/browser/month.pt object at 0x728f510>,
       'views': <zope.app.pagetemplate.viewpagetemplatefile.ViewMapper object at 0x7294090>}
  Module Products.PTProfiler.ProfilerPatch, line 32, in __patched_call__
  Module zope.tales.expressions, line 217, in __call__
  Module Products.PageTemplates.Expressions, line 161, in _eval
  Module Products.PageTemplates.Expressions, line 123, in render
  Module dateable.chronos.browser.month, line 145, in getPreviousViewUrl
ValueError: day is out of range for month
Steps to reproduce:
Travel back (or forward) to July, 31
Go to a calendar view that is using next/previous
receive ValueError
Added by Clayton Parker on Aug 01, 2008 01:37 AM
This has been fixed on the trunk at r69327

http://dev.plone.org/collective/changeset/69327

No responses can be added.