Utility can't find REQUEST

sirgarr georgeleejr at gmail.com
Thu Aug 30 05:18:03 UTC 2007


I am trying to code a utility as follows, but on runtime the call of
toLocalizedTime raises an AttributeError of REQUEST.  I thought that there
was a REQUEST somehow built in and lurking in the background when this code
got called -- for instance, doesn't getUtility know about the request and
use it to find the closest site manager?  How would I fix this code?



class DateRangeDisplayer(object):
    implements(IDateRangeDisplayer)

    def range_as_string(self, start, end):
        portal = getUtility(ISiteRoot)
        portal_properties = getUtility(IPropertiesTool)
        site_properties = portal_properties.site_properties

        if start.Date() != end.Date():
            return '%s to %s' % (
              portal.toLocalizedTime(start, long_format=1),
              portal.toLocalizedTime(end, long_format=1)
              )
-- 
View this message in context: http://www.nabble.com/Utility-can%27t-find-REQUEST-tf4351968s20094.html#a12400626
Sent from the Product Developers mailing list archive at Nabble.com.





More information about the Product-Developers mailing list