On Dec 11, 2007 2:23 PM, Christopher Arndt <[EMAIL PROTECTED]> wrote:
>
> Fred C schrieb:
> > On one of my production machines I have that problem and I don't know
> > how to fix it.
>
> Can you try applying the fix from changeset
> http://trac.turbogears.org/changeset/3807 or just install the recent
> version from SVN [1]?
>
>
> Chris
>
> [1] http://docs.turbogears.org/Contributing#id1
No, it won't work... :)
In Fred's first message, he paste the traceback, which ended with:
"
File "/usr/pkg/lib/python2.5/cgi.py", line 548, in __getattr__
raise AttributeError, name
AttributeError: encode
"
Looking at my python2.5 cgi.py, it is clear that he hit the following
method from cgi.FieldStorage:
def __getattr__(self, name):
if name != 'value':
raise AttributeError, name # <===== here it is
if self.file:
self.file.seek(0)
value = self.file.read()
self.file.seek(0)
elif self.list is not None:
value = self.list
else:
value = None
return value
Florent had the idea of checking if the object has an encode
attribute. Something like:
================
def encode_utf8(params):
'''
will recursively encode to utf-8 all values in a dictionnary
'''
res = dict()
for k, v in params.items():
if isinstance(v, dict):
res[k] = encode_utf8(v)
elif isinstance(v, list):
res[k] = [vv.encode('utf-8') for vv in v]
elif hasattr(v, 'encode'):
res[k] = v.encode('utf-8')
else:
res[k] = v
return res
================
Didn't test the code... but this should do the trick...
[]s
Roger
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---