Hello,
I got an interesting problem using flash with Cheetah templates, the
controller method goes like this:

@expose()
@validate(validators={"name":
validators.UnicodeString(not_empty=True)})
def save(self, name, submit, tg_errors=None):
    if tg_errors:
        flash(u"anything")
        redirect("/gizmos/new")
    flash(u"anything else")
    m = Gizmo()
    m.name = name
    m.file = sess["new_gizmo_file_absolute"]
    session.save(m)
    del(sess["new_gizmo_file_absolute"])
    del(sess["new_gizmo_file_relative"])
    redirect("/gizmos")

Now if there are no validation errors the flash(u"anything else")
executes just fine and the flash message is shown, yet if validation
fails I get this exception:

Page handler: <bound method Gizmos.new of <myapp.controllers.Gizmos
object at 0x8b63ccc>>
Traceback (most recent call last):
  File "/usr/local/lib/python2.5/site-packages/CherryPy-2.2.1-
py2.5.egg/cherrypy/_cphttptools.py", line 105, in _run
    self.main()
  File "/usr/local/lib/python2.5/site-packages/CherryPy-2.2.1-
py2.5.egg/cherrypy/_cphttptools.py", line 254, in main
    body = page_handler(*virtual_path, **self.params)
  File "<string>", line 3, in new
  File "/usr/lib/python2.5/site-packages/TurboGears-1.0.4b2-py2.5.egg/
turbogears/controllers.py", line 344, in expose
    *args, **kw)
  File "<string>", line 5, in run_with_transaction
  File "/usr/lib/python2.5/site-packages/TurboGears-1.0.4b2-py2.5.egg/
turbogears/database.py", line 366, in sa_rwt
    retval = func(*args, **kw)
  File "<string>", line 5, in _expose
  File "/usr/lib/python2.5/site-packages/TurboGears-1.0.4b2-py2.5.egg/
turbogears/controllers.py", line 359, in <lambda>
    mapping, fragment, args, kw)))
  File "/usr/lib/python2.5/site-packages/TurboGears-1.0.4b2-py2.5.egg/
turbogears/controllers.py", line 399, in _execute_func
    return _process_output(output, template, format, content_type,
mapping, fragment)
  File "/usr/lib/python2.5/site-packages/TurboGears-1.0.4b2-py2.5.egg/
turbogears/controllers.py", line 86, in _process_output
    fragment=fragment)
  File "/usr/lib/python2.5/site-packages/TurboGears-1.0.4b2-py2.5.egg/
turbogears/view/base.py", line 129, in render
    return engine.render(**kw)
  File "/usr/lib/python2.5/site-packages/TurboCheetah-1.0-py2.5.egg/
turbocheetah/cheetahsupport.py", line 112, in render
    return tempobj.respond()
  File "/home/myhome/Projects/myapp/myapp/templates/SiteTemplate.py",
line 276, in respond
    return _dummyTrans and trans.response().getvalue() or ""
  File "/usr/lib/python2.5/site-packages/Cheetah-2.0.1-py2.5-linux-
i686.egg/Cheetah/DummyTransaction.py", line 32, in getvalue
    return ''.join(outputChunks)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc4 in position
126: ordinal not in range(128)

If I change flash(u"anything) to flash(empty string) the exception is
not thrown.

Anyone know what could be wrong here?

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"TurboGears" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to