Here is how what I ended up with, in case of anyone interested:
@turbogears.expose(content_type="text/html; charset=UTF-8",
html="bookswap.templates.addbook")
def addbook(self, **kw):
### XXX: why this is needed?
for k,v in kw.items():
if isinstance(v, str): kw[k] = unicode(v, 'utf-8')
if kw: # feed data if any
addBookForm.input(kw)
cherrypy.request.input_values = kw # to display form with
data
if cherrypy.request.method == 'POST':
errors = cherrypy.request.form_errors
cherrypy.request.form_processed = True
if errors:
turbogears.flash(_('please correct errors below'))
else:
log.info("Adding book from %s", kw)
turbogears.flash(_('book has been added'))
turbogears.redirect('/addbook')
return dict(form=addBookForm)
Note the absense of inputform parameter in expose() and the need to set
cherrypy.request.input_values in order the form to be displayed filled
with user data.
A weird thing: yesterdays unicode data were handled OK by this
particular method but after today's SVN update it broke and I had to
add this hack in order to make it work again:
for k,v in kw.items():
if isinstance(v, str): kw[k] = unicode(v, 'utf-8')
Any ideas?