2011/1/5 Sergei Sadovski <[email protected]>:
> Hi, Guys,
>
> Thanks for points. Here some summary.
>
> event.description is <class
> 'google.appengine.api.datastore_types.Text'> instance contains text.
> This class defines as follow:
> class Text(unicode):
>  """A long string type.
>
>  Strings of any length can be stored in the datastore using this
>  type. It behaves identically to the Python unicode type, except for
>  the constructor, which only accepts str and unicode arguments.
>  """
>
> So, instance is actually an unicode.
>
> I did look into web/utils.py #safeunicode method and update code as
> follow:
>
> diff --git a/web/utils.py b/web/utils.py
> index 29a22d1..2d4846d 100755
> --- a/web/utils.py
> +++ b/web/utils.py
> @@ -320,7 +320,7 @@ def safeunicode(obj, encoding='utf-8'):
>         u'\u1234'
>     """
>     t = type(obj)
> -    if t is unicode:
> +    if isinstance(obj,unicode):
>         return obj
>     elif t is str:
>         return obj.decode(encoding)
>
> isinstance(object, classinfo)
>    Return true if the object argument is an instance of the classinfo
> argument, or of a (direct or indirect) subclass thereof...[1]
>
> Maybe should apply #isinstance to next elif statement, i.e. "elif t is
> str:"
> I dunno side-effect :) but looks like a good solution. I am new to
> python and 'd like to know your point on it?

That is the correct solution. I was actually about to ask you to try that.

Will fix that soon.

Anand

-- 
You received this message because you are subscribed to the Google Groups 
"web.py" 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/webpy?hl=en.

Reply via email to