Kung Fu Kung Fu

Fujian White Crane Kung Fu

Zope Zope

What I have and am doing with Zope

Photos Photos

Photoalbum, both old and new.

Receptsamlingen Receptsamlingen

In Swedish only. About my "Collection of Recipes" website.

Contact me Contact me

My contact details and how to contact me.

  Mobile version of this page Mobile version of this page


 

Entering multilanguage data in Zope

unicode strings, publisher, iso-8859-1, zpublisher

26th of November 2006

Zope is really great with it's publisher transform things that automatically cast HTTP GET or HTTP POST variables as proper python variables on the fly. I needed a form that asks for a Title and Description in multiple languages. The result I wanted passed into the saving method was variables like this:

 >>> titles
 {'en': u'London', 'sv': u'Stockholm'}
 >>> descriptions
 {'en': u'Capital', 'sv': u'Huvudstad'}

How did I write that form? Easy, here's the code:

 <b>Title</b><br />
 Svenska: <input name="title.sv:record" /><br />
 English: <input name="title.en:record" /><br />
 <b>Description</b>
 Svenska: <input name="description.sv:record" /><br />
 English: <input name="description.en:record" /><br />

And lastly, to get the unicoding right, you have to add the following so that the variable values are sent as iso-8859-1 encoded unicode strings:

 <b>Title</b><br />
 Svenska: <input name="title.sv:latin1:ustring:record" /><br />
 English: <input name="title.en:latin1:ustring:record" /><br />
 <b>Description</b>
 Svenska: <input name="description.sv:latin1:ustring:record" /><br />
 English: <input name="description.en:latin1:ustring:record" /><br />

Zope takes care of the rest and you can just sit back and enjoy the productivity.


Comment

 
Name:
Email:
hide my email address.

Your email address will be encoded to prevent email-extraction spiders from reading it so you won't get spammed if you decide to show your email address.