Re: Accessing POST Data More Than Once
Andi Scharfstein <[email protected]> Tue, 15 Nov 2005 18:40:49 +0100
| Newsgroups | gmane.comp.apache.mod-ruby |
|---|---|
| Message-ID | <[email protected]> |
Hi,
> 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.
> Any ideas on a work-around (other than re-writing the template system)?
Maybe the FAQ helps (don't know if it is applicable in your case, but
take a look):
http://wiki.modruby.net/en/?FAQ#How+do+I+keep+an+object+instance+between+invocations+of+a+page%2C+for+example%2C+a+persistent+database+handle%3F
require 'memory'
r = Apache.request
Memory.memory[:count] ||= 0
Memory.memory[:count] += 1
r.content_type = 'text/html'
r.send_http_header
r << "<html>Pid #{Process.pid}, memory count #{Memory.memory[:count]}</html>"
[file memory.rb]
class Memory
def self.memory
@memory ||= {}
end
end
--
HTH: Andi S. mailto:[email protected]