durusmail: quixote-users: "coercing to Unicode" error
"coercing to Unicode" error
"coercing to Unicode" error
Robert Leftwich
2004-11-21
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.

Robert



reply