[Zope] DTML-SQLVAR and Unicode and PostgreSQL
Glenn R Williams
22 May 2003 20:29:58 -0400
The query I am using was created by a adding a Z Sql method, and I enter
the input into the test field. Looking at the Zope log, it is using a
GET method and passing the server a string like this (splitting the line
%D9%8A%D8%AF&SUBMIT=3DSubmit+Query" "Mozilla/5.0 (X11; U; Linux i686; en-US=
; rv:1.3) Gecko/20030420"
This seems correct so far. So the problem may be in the Databas adaptor
(ZPsycopgDA). I'll let you know if I find anything.
Thanks again for you help,
On Thu, 2003-05-22 at 14:08, Dieter Maurer wrote:
> Glenn R Williams wrote at 2003-5-21 17:58 -0400:
> > I got one step further: the PostgreSQL log shows my query with convert=
> > HTML entites:
> > LOG: query: select * from xp_name
> > where original_name =3D =20
> > 'عامررشيد=
> > As you can see, this is not what I want! But how do I tell Zope to use
> > utf8 encoding for the query? When building the query in Zope, I
> > specified as an argumen "original_name:ustring". However, the actual
> > query in the Z SQL method only allows a type of "string".=20
> > Am I doing something wrong?
> Not you, but someone does...
> I fear it is your browser.
> We must find out who decides to code the arabic characters as
> XML/SGML character references.
> You told us that the value came from an HTML form, right?
> I expect, it was a form "POST"ed to the server.
> Apparently, the browser used a Content-Type ("text/sgml" or "text/xml")
> which Zope does not expect and interpret wrongly.
> I see several options:
> * Use 'METHOD=3D"GET"' in your form. This forces a standard
> compliant browser to use URL-encoding (with characters
> first encoded as UTF-8 and then url-escaped).
> * HTML allows the server to control the content-types
> for form variables. Try to use the corresponding attribute
> to forbid "text/sgml", "text/xml".
> * Convert the character references yourself into UTF-8.
> This is easy: first convert to unicode (with "unichr")
> then encode the resulting unicode string as UTF-8
> (with the unicode object's "encode" method).
> The last option is probably the most robust one.
> Zope maillist - Zope@zope.org
> ** No cross posts or HTML encoding! **
> (Related lists -=20
> http://mail.zope.org/mailman/listinfo/zope-dev )
Glenn R Williams
Mathematical theories are the part of science you could continue to do
if you woke up tomorrow and discovered the universe was gone.
Content-Type: application/pgp-signature; name=signature.asc
Content-Description: This is a digitally signed message part
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)
-----END PGP SIGNATURE-----