diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2006-07-30 14:06:50 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2006-07-30 14:06:50 +0000 |
commit | 7639df765e1b6d3d4ad5f016a68d15c19fd870ee (patch) | |
tree | 7a6b3c14fc6eb9e548221ce93b5872f232c6e755 /lib/cgi | |
parent | b1c99d570b4871a10fb6cd7224dc37e766f7f62b (diff) | |
download | ruby-7639df765e1b6d3d4ad5f016a68d15c19fd870ee.tar.gz |
* lib/cgi/session.rb, lib/cgi/session/pstore.rb: suppress warnings.
fixed: [ruby-talk:204896]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@10643 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/cgi')
-rw-r--r-- | lib/cgi/session.rb | 18 | ||||
-rw-r--r-- | lib/cgi/session/pstore.rb | 17 |
2 files changed, 11 insertions, 24 deletions
diff --git a/lib/cgi/session.rb b/lib/cgi/session.rb index 562e571cd5..82eb7534d8 100644 --- a/lib/cgi/session.rb +++ b/lib/cgi/session.rb @@ -301,20 +301,14 @@ class CGI # Retrieve the session data for key +key+. def [](key) - unless @data - @data = @dbman.restore - end + @data ||= @dbman.restore @data[key] end # Set the session date for key +key+. def []=(key, val) - unless @write_lock - @write_lock = true - end - unless @data - @data = @dbman.restore - end + @write_lock ||= true + @data ||= @dbman.restore @data[key] = val end @@ -374,13 +368,15 @@ class CGI # not exist, or opened if it does. def initialize(session, option={}) dir = option['tmpdir'] || Dir::tmpdir - prefix = option['prefix'] || '' + prefix = option['prefix'] || '' suffix = option['suffix'] || '' id = session.session_id require 'digest/md5' md5 = Digest::MD5.hexdigest(id)[0,16] @path = dir+"/"+prefix+md5+suffix - unless File::exist? @path + if File::exist? @path + @hash = nil + else unless session.new_session raise CGI::Session::NoSession, "uninitialized session" end diff --git a/lib/cgi/session/pstore.rb b/lib/cgi/session/pstore.rb index 696f6f2d3b..bd93d0a6ff 100644 --- a/lib/cgi/session/pstore.rb +++ b/lib/cgi/session/pstore.rb @@ -14,17 +14,6 @@ require 'pstore' class CGI class Session - def []=(key, val) - unless @write_lock - @write_lock = true - end - unless @data - @data = @dbman.restore - end - #@data[key] = String(val) - @data[key] = val - end - # PStore-based session storage class. # # This builds upon the top-level PStore class provided by the @@ -53,7 +42,7 @@ class CGI # # This session's PStore file will be created if it does # not exist, or opened if it does. - def initialize session, option={} + def initialize(session, option={}) dir = option['tmpdir'] || Dir::tmpdir prefix = option['prefix'] || '' id = session.session_id @@ -61,7 +50,9 @@ class CGI md5 = Digest::MD5.hexdigest(id)[0,16] path = dir+"/"+prefix+md5 path.untaint - unless File::exist?(path) + if File::exist?(path) + @hash = nil + else unless session.new_session raise CGI::Session::NoSession, "uninitialized session" end |