durusmail: quixote-users: Problems with Strings
Problems with Strings
2005-03-27
2005-03-27
2005-03-27
Problems with Strings
Andy Todd
2005-03-27
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',) I can't replicate this in an interactive session of course. Changing the method type from [html] to [plain] works just fine, but according to the documentation [1] it's better to use the former and I'm trying to be good here. I thought by explicitly converting the results of get_environ to a string I would solve the problem but this isn't the case. The only thing I've tried that works is changing the method type. Changing the function to; def delete [html] (self, request): queryString = str(request.get_environ('QUERY_STRING')) '

queryString is %s

\n' % type(queryString Gives an output of; """ queryString is """ Which is why I thought I could use the find method on it. Any explanation of what I'm missing would be much appreciated. [1] http://www.mems-exchange.org/software/quixote/doc/PTL.html Regards, Andy -- -------------------------------------------------------------------------------- From the desk of Andrew J Todd esq - http://www.halfcooked.com/
reply