(Moving the below over from mod_ruby to the larger audience on ruby-talk.)
Hi,
Our complex custom template system requires a file containing a class called Page. Depending on the particular configuration of a given page, Page can get initialized several times. Page has a method to fetch CGI parameters (calls @cgi.params.dup where @cgi has been initialized to CGI.new). The first time this method is called, things work. Subsequent calls don't work under Ubuntu 5.04/Ruby 1.8(libapache2-mod-ruby 1.2.4-1)/Apache2. They did under Debian 3.0/Ruby1.6/Apahce1.3.
I tried setting a class variable with cgi.params the first time Page is initialized. This didn't work because we're using mod_ruby and Apache2 which caches code in memory between requests.
Digging down to the mod_ruby level (bypassing CGI):
If I submit data using the example below, the first Apache.request.read returns the POSTed data while subsequent calls return nil instead of repeating the POSTed data. So, we get the same problem as we do with CGI.
Using multiple instances of CGI or directly via mod_ruby, how do I access POSTed data more than one time from a script?
Thank you,
Ben Gribaudo
<pre>
<%
puts Apache.request.read # expected data
puts Apache.request.read # nil
%>
</pre>
<form method="post">
<input type="text" name="test" />
<input type="submit" />
</form>