[Zope] DTML-SQLVAR and Unicode and PostgreSQL

Glenn R Williams gloonie@earthlink.net
22 May 2003 20:29:58 -0400


--=-rGzQy0f1jGFrx6trAUqR
Content-Type: text/plain
Content-Transfer-Encoding: quoted-printable

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
for readability):

"http://localhost:8080/gloonie/xpersec/sqlFindNames/
manage_test?original_name%3Austring=3D%D8%B9%D8%A7%D9%85%D8%B1+%D8%B1%D8%B4=
%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,

Glenn

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=
ed
>  > HTML entites:
>  >=20
>  > LOG:  query: select * from xp_name
>  >               where original_name =3D            =20
>  >               'عامررشي&#1583=
;'
>  >=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
>  >=20
>  > Am I doing something wrong?
>=20
> Not you, but someone does...
>=20
>    I fear it is your browser.
>=20
> We must find out who decides to code the arabic characters as
> XML/SGML character references.
>=20
> 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.
>=20
> I see several options:
>=20
>   *  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).
>=20
>   *  HTML allows the server to control the content-types
>      for form variables. Try to use the corresponding attribute
>      to forbid "text/sgml", "text/xml".
>=20
>   *  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).
>=20
> The last option is probably the most robust one.
>=20
>=20
> Dieter
>=20
> _______________________________________________
> Zope maillist  -  Zope@zope.org
> http://mail.zope.org/mailman/listinfo/zope
> **   No cross posts or HTML encoding!  **
> (Related lists -=20
>  http://mail.zope.org/mailman/listinfo/zope-announce
>  http://mail.zope.org/mailman/listinfo/zope-dev )
--=20
Glenn R Williams
Ghoti Software
----------------------------------------------------------------------
Mathematical theories are the part of science you could continue to do
if you woke up tomorrow and discovered the universe was gone.

--=-rGzQy0f1jGFrx6trAUqR
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)

iD8DBQA+zWuFQ0pkIU7d8owRAurlAKCg/VcRv/u5A/OzZHyYZccLTo9QugCdHSuM
JEc8zobBeHoWvGyNomTx5qU=
=YM2m
-----END PGP SIGNATURE-----

--=-rGzQy0f1jGFrx6trAUqR--