Changeset 2230
- Timestamp:
- 09/13/05 08:31:32 (3 years ago)
- Files:
-
- trunk/actionpack/CHANGELOG (modified) (1 diff)
- trunk/actionpack/lib/action_controller.rb (modified) (2 diffs)
- trunk/actionpack/lib/action_controller/caching.rb (modified) (5 diffs)
- trunk/actionpack/lib/action_controller/cgi_process.rb (modified) (1 diff)
- trunk/actionpack/lib/action_controller/session_management.rb (modified) (4 diffs)
- trunk/actionpack/lib/action_controller/session.rb (deleted)
- trunk/actionpack/test/controller/fragment_store_setting_test.rb (added)
- trunk/actionpack/test/controller/session_management_test.rb (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/actionpack/CHANGELOG
r2228 r2230 1 1 *SVN* 2 3 * Added easy assignment of fragment cache store through use of symbols for included stores (old way still works too) 4 5 Before: 6 ActionController::Base.fragment_cache_store = 7 ActionController::Base::Caching::Fragments::FileStore.new("/path/to/cache/directory") 8 9 After: 10 ActionController::Base.fragment_cache_store = :file_store, "/path/to/cache/directory" 2 11 3 12 * Added ActionController::Base.session_store=, session_store, and session_options to make it easier to tweak the session options (instead of going straight to ActionController::CgiRequest::DEFAULT_SESSION_OPTIONS) trunk/actionpack/lib/action_controller.rb
r2191 r2230 39 39 require 'action_controller/layout' 40 40 require 'action_controller/flash' 41 require 'action_controller/session'42 41 require 'action_controller/dependencies' 43 42 require 'action_controller/pagination' … … 68 67 include ActionController::Helpers 69 68 include ActionController::Cookies 70 include ActionController::Session71 69 include ActionController::Caching 72 70 include ActionController::Components trunk/actionpack/lib/action_controller/caching.rb
r2142 r2230 241 241 # Configuration examples (MemoryStore is the default): 242 242 # 243 # ActionController::Base.fragment_cache_store = 244 # ActionController::Caching::Fragments::MemoryStore.new 245 # 246 # ActionController::Base.fragment_cache_store = 247 # ActionController::Caching::Fragments::FileStore.new("/path/to/cache/directory") 248 # 249 # ActionController::Base.fragment_cache_store = 250 # ActionController::Caching::Fragments::DRbStore.new("druby://localhost:9192") 251 # 252 # ActionController::Base.fragment_cache_store = 253 # ActionController::Caching::Fragments::MemCacheStore.new("localhost") 243 # ActionController::Base.fragment_cache_store = :memory_store 244 # ActionController::Base.fragment_cache_store = :file_store, "/path/to/cache/directory" 245 # ActionController::Base.fragment_cache_store = :drb_store, "druby://localhost:9192" 246 # ActionController::Base.fragment_cache_store = :mem_cache_store, "localhost" 247 # ActionController::Base.fragment_cache_store = MyOwnStore.new("parameter") 254 248 module Fragments 255 249 def self.append_features(base) #:nodoc: … … 257 251 base.class_eval do 258 252 @@fragment_cache_store = MemoryStore.new 259 cattr_accessor :fragment_cache_store 253 cattr_reader :fragment_cache_store 254 255 def self.fragment_cache_store=(store_option) 256 store, *parameters = *([ store_option ].flatten) 257 @@fragment_cache_store = if store.is_a?(Symbol) 258 store_class_name = (store == :drb_store ? "DRbStore" : store.to_s.camelize) 259 store_class = ActionController::Caching::Fragments.const_get(store_class_name) 260 parameters.empty? ? store.new : store_class.new(*parameters) 261 else 262 store 263 end 264 end 260 265 end 261 266 end … … 350 355 351 356 class DRbStore < MemoryStore #:nodoc: 357 attr_reader :address 358 352 359 def initialize(address = 'druby://localhost:9192') 360 @address = address 353 361 @data, @mutex = DRbObject.new(nil, address), Mutex.new 354 362 end … … 356 364 357 365 class MemCacheStore < MemoryStore #:nodoc: 366 attr_reader :address 367 358 368 def initialize(address = 'localhost') 369 @address = address 359 370 @data, @mutex = MemCache.new(address), Mutex.new 360 371 end … … 362 373 363 374 class FileStore #:nodoc: 375 attr_reader :cache_path 376 364 377 def initialize(cache_path) 365 378 @cache_path = cache_path trunk/actionpack/lib/action_controller/cgi_process.rb
r2151 r2230 2 2 require 'action_controller/cgi_ext/cookie_performance_fix' 3 3 require 'action_controller/cgi_ext/raw_post_data_fix' 4 require 'action_controller/session/drb_store'5 require 'action_controller/session/mem_cache_store'6 if Object.const_defined?(:ActiveRecord)7 require 'action_controller/session/active_record_store'8 end9 4 10 5 module ActionController #:nodoc: trunk/actionpack/lib/action_controller/session_management.rb
r2229 r2230 1 require 'action_controller/session/drb_store' 2 require 'action_controller/session/mem_cache_store' 3 if Object.const_defined?(:ActiveRecord) 4 require 'action_controller/session/active_record_store' 5 end 6 1 7 module ActionController #:nodoc: 2 8 module SessionManagement #:nodoc: … … 4 10 super 5 11 base.extend(ClassMethods) 6 base.class_eval do 7 alias_method :process_without_session_management_support, :process 8 alias_method :process, :process_with_session_management_support 9 end 12 base.send(:alias_method, :process_without_session_management_support, :process) 13 base.send(:alias_method, :process, :process_with_session_management_support) 14 base.after_filter(:clear_persistant_model_associations) 10 15 end 11 16 … … 16 21 def session_store=(store) 17 22 ActionController::CgiRequest::DEFAULT_SESSION_OPTIONS[:database_manager] = 18 store.is_a?(Symbol) ? CGI::Session.const_get(store .to_s.camelize) : store23 store.is_a?(Symbol) ? CGI::Session.const_get(store == :drb_store ? "DRbStore" : store.to_s.camelize) : store 19 24 end 20 25 … … 101 106 process_without_session_management_support(request, response, method, *arguments) 102 107 end 108 109 private 110 def clear_persistant_model_associations #:doc: 111 session = @session.instance_variable_get("@data") 112 session.each { |key, obj| obj.clear_association_cache if obj.respond_to?(:clear_association_cache) } if session 113 end 103 114 end 104 115 end trunk/actionpack/test/controller/session_management_test.rb
r2031 r2230 82 82 assert_equal false, @request.session_options 83 83 end 84 85 def test_session_store_setting 86 ActionController::Base.session_store = :drb_store 87 assert_equal CGI::Session::DRbStore, ActionController::Base.session_store 88 89 if Object.const_defined?(:ActiveRecord) 90 ActionController::Base.session_store = :active_record_store 91 assert_equal CGI::Session::ActiveRecordStore, ActionController::Base.session_store 92 end 93 end 84 94 end