Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Changeset 3100

Show
Ignore:
Timestamp:
11/20/05 04:41:59 (3 years ago)
Author:
bitsweat
Message:

r3173@asus: jeremy | 2005-11-18 23:34:41 -0800
Ticket 2731 - sessions
r3185@asus: jeremy | 2005-11-19 18:02:51 -0800
eliminate const redefinition warning
r3186@asus: jeremy | 2005-11-19 19:25:50 -0800
Use :database option instead of :dbfile
r3187@asus: jeremy | 2005-11-19 19:34:31 -0800
Data writer assigns to instance var. Since nothing is calling write_attribute on the data column except for marshal_data, simplify data reader to lazy-unmarshal the data column (no worrying whether it's already unmarshaled)
r3188@asus: jeremy | 2005-11-19 19:35:40 -0800
Explicitly create the session class so that subsequent requests for the session can find it in the database. This is masking a problem with the controller losing its @session instance var and therefore requesting a new session.
r3189@asus: jeremy | 2005-11-19 19:36:40 -0800
Using create unnecessarily broadens the existing duck-typing so use new + save instead.
r3194@asus: jeremy | 2005-11-19 20:28:17 -0800
Test creation of another instance while first instance is still active. Should return same session_id.
r3195@asus: jeremy | 2005-11-19 20:39:45 -0800
Always create new AR sessions rather than trying too hard to avoid database traffic. References #2731.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/actionpack/CHANGELOG

    r3091 r3100  
    11*SVN* 
     2 
     3* Always create new AR sessions rather than trying too hard to avoid database traffic.  #2731 [Jeremy Kemper] 
    24 
    35* Update to Prototype 1.4.0_rc4. Closes #2943 (old Array.prototype.reverse behavior can be obtained by passing false as an argument). [Sam Stephenson] 
  • trunk/actionpack/lib/action_controller/session/active_record_store.rb

    r2944 r3100  
    118118        end 
    119119 
     120        attr_writer :data 
     121 
    120122        # Lazy-unmarshal session state. 
    121123        def data 
    122           unless @data 
    123             case d = read_attribute(@@data_column_name) 
    124               when String 
    125                 @data = self.class.unmarshal(d) 
    126               else 
    127                 @data = d || {} 
    128             end 
    129           end 
    130           @data 
     124          @data ||= self.class.unmarshal(read_attribute(@@data_column_name)) 
    131125        end 
    132126 
     
    285279          end 
    286280          @session = @@session_class.new(:session_id => session_id, :data => {}) 
     281          @session.save 
    287282        end 
    288283      end 
  • trunk/actionpack/lib/action_view/helpers/asset_tag_helper.rb

    r2835 r3100  
    3636      end 
    3737 
    38       JAVASCRIPT_DEFAULT_SOURCES = ['prototype', 'effects', 'dragdrop', 'controls'] 
     38      JAVASCRIPT_DEFAULT_SOURCES = ['prototype', 'effects', 'dragdrop', 'controls'] unless const_defined?(:JAVASCRIPT_DEFAULT_SOURCES) 
    3939      @@javascript_default_sources = JAVASCRIPT_DEFAULT_SOURCES.dup 
    4040 
  • trunk/actionpack/test/controller/active_record_store_test.rb

    r2944 r3100  
    1616#ActiveRecord::Base.logger = Logger.new($stdout) 
    1717begin 
    18   CGI::Session::ActiveRecordStore::Session.establish_connection(:adapter => 'sqlite3', :dbfile => ':memory:') 
     18  CGI::Session::ActiveRecordStore::Session.establish_connection(:adapter => 'sqlite3', :database => ':memory:') 
    1919  CGI::Session::ActiveRecordStore::Session.connection 
    2020rescue Object 
    2121  $stderr.puts 'SQLite 3 unavailable; falling back to SQLite 2.' 
    2222  begin 
    23     CGI::Session::ActiveRecordStore::Session.establish_connection(:adapter => 'sqlite', :dbfile => ':memory:') 
     23    CGI::Session::ActiveRecordStore::Session.establish_connection(:adapter => 'sqlite', :database => ':memory:') 
    2424    CGI::Session::ActiveRecordStore::Session.connection 
    2525  rescue Object 
     
    6969    CGI::Session::ActiveRecordStore.session_class = session_class 
    7070 
    71     @new_session = CGI::Session.new(CGI.new, 'database_manager' => CGI::Session::ActiveRecordStore, 'new_session' => true) 
     71    @cgi = CGI.new 
     72    @new_session = CGI::Session.new(@cgi, 'database_manager' => CGI::Session::ActiveRecordStore, 'new_session' => true) 
    7273    @new_session['foo'] = 'bar' 
     74  end 
     75 
     76  def test_another_instance 
     77    @another = CGI::Session.new(@cgi, 'session_id' => @new_session.session_id, 'database_manager' => CGI::Session::ActiveRecordStore) 
     78    assert_equal @new_session.session_id, @another.session_id 
    7379  end 
    7480