From: matz@... (Yukihiro Matsumoto) Date: 2001-09-19T17:39:39+09:00 Subject: [ruby-talk:21383] Re: Suggestions for new CGI lib Hi, In message "[ruby-talk:21381] Re: Suggestions for new CGI lib" on 01/09/19, Anders Johannsen writes: |> What should these methods return? cgi.rb returns an array of values, |> but it's not convenient for many cases. | |A String (since each of cgi.request.(post|get|cookie|env|var) |effectively is a Hash) Then what if there are multiple values for a form name, for example: GET /script.cgi?user_var=foo&user_var=bar HTTP/1.1 Host: www.example.com Connection: close What should be returned for cgi.request["user_var"]? Possible solution can be any of: * "foo\0bar" (Perl's cgi-lib.pl and cgi-lib.rb) * ["foo", "bar"] (cgi.rb) * # (Python's cgi.py) * or something else FYI, single value results are following respectively: * "foo" (Perl's cgi-lib.pl and cgi-lib.rb) * ["foo"] (cgi.rb) * # (Python's cgi.py) Probably most natural solution is "foo" for single value, and ["foo", "bar"] for multiple values, although it's little bit inconsistent. |> |CGI::Namespace # cgi.namespace |> |> | # Introduce new namespace with the indicated variables exported |> |(non-existant variables is nil) |> | cgi.namespace.var do |> | unless non_existant_var.nil? |> | # Do stuff |> | end |> | end |> |> I'm not sure what this method does. | |In the above example, cgi.request.var['user_var'] is availiable as |user_var inside the block. Non existant variables/methods return nil |instead of raising a NameError exception. Perhaps it is a silly |thought. Hmm, I don't think it's not possible for Ruby to add local variable without declaration (unless you use magic using internal). |> What do you think about HTML generation? Some want it separated from |> CGI. The current CGI::Session uses this integration. | |I would like to see them seperated. CGI is not necessarily used for |HTML. I agree conceptually. My only concern is how to implement CGI session. matz.