[Seaside] 3.9 and encoding in multipart fields
Norbert Hartl
norbert at hartl.name
Thu Apr 26 21:42:45 UTC 2007
On Thu, 2007-04-26 at 23:17 +0200, Philippe Marschall wrote:
> 2007/4/26, Norbert Hartl <norbert at hartl.name>:
> > .
> > > Hmmm, it is still not working. I have two forms. One is only text fields
> > > (multipart false) and one is text fields and input type="file"
> > > (multipart true). I store the values in the database using Glorp.
> > > I have two modifications to convert strings. One to utf8 when storing
> > > in the database and one to convert from utf8 when reading from the
> > > database.
> > >
> > > The multipart=false case leads to a proper store of the string in the
> > > database. The multipart=true does not. Using WAKomEncoded39 the none
> > > multipart case is displayed correctly. With WAKom the multipart case
> > > is displayed correct.
> > >
> > > Examine the kom requests I can see that on multipart=false the strings
> > > are displaying correct in the inspector. With multipart=true the
> > > strings are looking strange (no conversion to the squeak encoding???)
> > >
> > > I don't know much about the multipart stuff. Are the single parts from
> > > a multipart recognizable of which type they are (binary or text). I
> > > would like to do a conversion if it is text. Do you have any hint where
> > > in WAKom this encoding should occurr.
> > >
> > Ok, now I tested my theory. I added some code to WAKom to convert
> > multipart fields to an internal representation.
> >
> > processMultipartFields: aRequest
> > aRequest multipartFormFieldsDo:
> > [:chunk |
> > chunk explore.
> > chunk fileName isEmptyOrNil ifFalse:
> > [|stream file|
> > stream := WriteStream on: String new.
> > chunk saveToStream: stream.
> > file := WAFile new
> > fileName: chunk fileName;
> > contents: stream contents;
> > contentType: chunk contentType;
> > yourself.
> > aRequest postFields at: chunk fieldName put: file]
> > ifTrue: [
> > |stream|
> > stream := WriteStream on: String new.
> > chunk saveToStream: stream.
> >
> > aRequest postFields at: chunk fieldName put:( (stream contents)
> > convertFromEncoding: #utf8)]
> > ].
>
> Do I see correctly that the #ifTrue: part ist new?
>
yes.
> > That works for me now. It is slower than any other approach while
> > doing:
> >
> > - getting UTF-8 from the client (is that always true or how does WAKom
> > decide?)
>
> WAKom does _nothing_ whatever the clients sends to you in whatever
> encoding will be what you get.
>
Ok, that isn't very good. So I have to figure out the cases where I
don't get utf-8 and cope with that.
> > - converting multipart and none multipart fields from utf-8 to squeak
> > - converting the string to utf-8 when storing in the database of the
> > PostgresQL client encoding utf-8
>
> Your job. Seaside does not know or care about databases.
>
Seaside doesn't but squeak should :)
> > ....
> > - converting from utf-8 when reading from the database
>
> See above.
>
> > - Using WAKomEncoded39 which encodes to utf-8 before sending to the
> > client.
> >
> > It is much encoding but relatively clean (I think). I can use Umlauts
> > in squeak code (being squeak encoding).
>
> Yes, in Squeak >= 3.8 and WAKomEncoded(39)
That is what I'm using.
Norbert
More information about the seaside
mailing list