[Zope] RE: Help with Japanese rendering in Zope...?
Erik Anderson
erikanderson3 at yahoo.com
Wed Dec 10 21:43:17 EST 2003
Hey there Bjorn --
Finally found the time to try out dump_obj, and it's showing me that
everything *should* be stored correctly in Unicode. Furthermore, the
properties page itself (sample attached) does correctly identify the
input as UTF-8. However, the results of my simple dtml method still
show question marks, even when I look at the source of the generated
page (attached, along with the results of dump_obj).
Given that the dtml-method result page *source* shows question marks in
place of proper Japanese, it suggests to me that something isn't
returning properly. Perhaps some intermediary function is not
Unicode-aware and fills in the non-ascii chars with question marks?
Thanks too for your Plone suggestion. I'm wading through the Plone and
Archetype documentation, but it's a bit thin on the right kind of
detail for a Plone/Zope newbie like me. I appreciate your time in
helping me out.
Cheers,
Erik Anderson
--- Bjorn Stabell <bjorn at stabell.name> wrote:
> Hi Erik,
>
> I'd recommend you get and install Plone+CMF+Zope from plone.org
> instead
> of trying to find all the correct products of the right versions
> yourself.
>
> As for your problem displaying Japanese characters, it does sound
> like
> you're running into a unicode encoding/decoding problem.
>
> If your properties are stored as unicode, Zope will automatically
> encode
> them in the output character encoding (in your case, this seems to be
> UTF-8).
>
> Getting the input from your form decoded propertly takes a bit more
> work, though. Make sure all HTML text field names have :ustring:utf8
> (or uline, utokens, or utext) appended to them, e.g.,
>
> <input type="text" name="title:ustring:utf8">
>
> Zope will look at the name of the field when guessing at which
> character
> encoding the text is in, and then decode it into a unicode string
> (which
> is stored using Python's internal encoding). This type of string
> will
> be of type "ustring".
>
> To double-check that your strings are really stored as ustrings (they
> will look like u"hello", not "hello"), install and run the attached
> dump_obj external method on your object.
>
> If this discussion continues, let's move this discussion to the Zope
> list (zope at zope.org) so that it gets archived and others can learn
> from
> it and help with it as well.
>
> Bye,
> --
> Bjorn
>
> ATTACHMENT part 2 message/rfc822
> From: "Admin-Unix2" <admin at exoweb.net>
> To: "Bjorn Stabell" <bjorn at exoweb.net>
> Date: Thu, 4 Dec 2003 14:12:59 +0800
>
> # TODO:
> # - editing interface (open new window for each property)
> # - also list functions
> # - searching/ filtering
> # - collapse/ expand (dynamically load)
> # - include size information
> # - include cache information (ghosted or active)
> #
> # IDEAS:
> # - add debug to URL to have execution traced in a separate window,
> e.g.,
> # .../debug/login_form
>
> from DocumentTemplate.html_quote import html_quote
>
> def dump_obj(self, depth=10):
> #
> # don't go too deep
> #
> if depth<0: return `self`
> out = ""
>
> #
> # images; also show them
> #
> if hasattr(self, 'tag'):
> out += '<IMG SRC="'+self.getId()+'" style="float:
> right;"/>'
> #return self.tag(self) TODO: acquisition doesn't work?
> # files TODO: add link for downloading
>
> #
> # list-like types
> #
> if type(self) in [type([]), type(())]:
> out += "\n"
> for item in self:
> out += "<DIV style='border-top: solid #cccccc
> 1px;'>"+dump_obj(item)+"</DIV>"
> return out
>
> #
> # dictionary-like types (including objects)
> #
> d = {}
> if type(self) is type({}): # dictionaries
> d = self
> elif hasattr(self, '__dict__'): # objects
> d = self.__dict__
> if d:
> out += "<TABLE>\n"
> for key,val in d.items():
> out += "<TR>"
> out += "<TH align=left valign=top>"
> out += "<a
> title=\""+html_quote(str(type(val)))+"\">"+str(key)+"</a>"
> out += "</TH>"
> out += "<TD valign=top style='border: solid
> #669966 1px;'>"
> if type(d) is type({}):
> out += dump_obj(val, depth-1)
> else:
> out += dump_obj(getattr(d, key),
> depth-1)
> out += "</TD></TR>\n"
> out += "</TABLE>\n"
> return out
>
> #
> # basic types
> #
> s = `self`
> if len(s) > 400:
> out += html_quote(s[:400])+'<b style="color:
> #cc3300;">...</b>'
> else:
> out += html_quote(s)
> return out
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.zope.org/pipermail/zope/attachments/20031210/d5bb86b4/Post03-12-11--kiru.html
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.zope.org/pipermail/zope/attachments/20031210/d5bb86b4/Post03-12-11--kiruprops.html
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.zope.org/pipermail/zope/attachments/20031210/d5bb86b4/Post03-12-11--dump_obj.html
More information about the Zope
mailing list