On 1/24/06, Mike Sarahan <[EMAIL PROTECTED]> wrote:
>
>   File
> "/home/.castor/mikez0r/elementarycatastrophe.com/photogal/photogal/contro
> llers.py", line 416, in edit
>     itemlist=itemlist+'%s=%s&' % name,value
> TypeError: not enough arguments for format string
>

I would just add an "if" to make sure you have both a name and a
value.  Some items in cherrypy.request.paramMap *could* have values of
None, in which case string substitution will probably fail.

I also don't like the way you're building the string, but that's
because I'm a picky person. :)

My version of your code (n.b. written in email, so excuse any silly typos):


       @turbogears.expose()
       def logout( self ):
               identity.current.logout()
               previous_url =
cherrypy.request.headerMap.get("Referer", "/")
               original_parameters=cherrypy.request.paramMap
               #Changes start here
               itemlist = ["%s=%s" % (name,value) for name,value in
original_parameters.items() if name and value]
               itemstring = "?%s" % "&".join(itemlist)
               previous_url=previous_url[52:]+itemstring
               raise turbogears.redirect(previous_url)

This will of course filter any values that are None.  If you do not
want this behaviour then I would lose the "if name and value" in the
list comprehension and wrap both name and value in str().

Hope this helps.

Lee

Reply via email to