durusmail: quixote-users: "coercing to Unicode" error
"coercing to Unicode" error
"coercing to Unicode" error
jbdunsmo@utmb.edu
2004-11-21
On Mon, Nov 22, 2004 at 07:28:20AM +1100, Robert Leftwich wrote:
> jbdunsmo@utmb.edu wrote:
> >i'm trying to simply put the modification date of a file in a
> >template:
> >
> >def page_footer [html] ():
> >    '''
> >blah %s blah
> >''' % time.ctime(os.path.getmtime(path + 'pages.ptl'))
> >
> >....but i get this error:
> >
> >TypeError: coercing to Unicode: need string or buffer, htmltext found
> >
> >it should've been converted to a string.  why does it say htmltext is
> >found?
>
> Because all strings in a PTL file are 'wrapped' as htmltext for safety. You
> can use str('pages.ptl') to get at the 'unwrapped' string.
>

thanks robert.  this worked:

def page_footer [html] ():
    '''
blah %s blah
''' % time.ctime(os.path.getmtime(path + str('pages.ptl')))


reply