durusmail: quixote-users: Problems with Strings
Problems with Strings
2005-03-27
2005-03-27
2005-03-27
Problems with Strings
David Binger
2005-03-27
On Mar 27, 2005, at 7:23 AM, Andy Todd wrote:

> I'm presuming that I'm missing something really straight forward here,
> but I'm having some problems with strings.
>
> In my PTL module I've got the following method;
>
>     def delete [html] (self, request)
>         '     

Delete Page

\n' > queryString = str(request.get_environ('QUERY_STRING')) > '

queryString is %s

\n' % queryString > # If the queryString includes 'confirm=yes' then delete the > page, > if queryString.find("confirm") != -1: > '

Really delete this page?\n' > > But when I run it I get an error raised by the 'if' statement; > > TypeError: expected a character buffer object > args = ('expected a character buffer object',) The "confirm" literal within an [html] template is of type 'htmltext', which the str.find() method can't handle. You can write instead: if querytring.find(str("confirm")) != -1: ...

reply