From 21aa32692caf91f56d1c5c411baae635fa398344 Mon Sep 17 00:00:00 2001 From: Joshua Peek Date: Mon, 27 Apr 2009 13:11:17 -0500 Subject: Delegate controller.session to request.session and deprecate response session --- actionpack/lib/action_controller/base/base.rb | 14 +++++--------- actionpack/lib/action_controller/testing/process.rb | 2 +- actionpack/lib/action_dispatch/http/request.rb | 8 -------- actionpack/lib/action_dispatch/http/response.rb | 6 +++++- 4 files changed, 11 insertions(+), 19 deletions(-) (limited to 'actionpack/lib') diff --git a/actionpack/lib/action_controller/base/base.rb b/actionpack/lib/action_controller/base/base.rb index afb9fb71cb..1d0738588d 100644 --- a/actionpack/lib/action_controller/base/base.rb +++ b/actionpack/lib/action_controller/base/base.rb @@ -238,7 +238,7 @@ module ActionController #:nodoc: cattr_reader :protected_instance_variables # Controller specific instance variables which will not be accessible inside views. @@protected_instance_variables = %w(@assigns @performed_redirect @performed_render @variables_added @request_origin @url @parent_controller - @action_name @before_filter_chain_aborted @action_cache_path @_session @_headers @_params + @action_name @before_filter_chain_aborted @action_cache_path @_headers @_params @_flash @_response) # Prepends all the URL-generating helpers from AssetHelper. This makes it possible to easily move javascripts, stylesheets, @@ -356,7 +356,9 @@ module ActionController #:nodoc: # Holds a hash of objects in the session. Accessed like session[:person] to get the object tied to the "person" # key. The session will hold any type of object as values, but the key should be a string or symbol. - attr_internal :session + def session + request.session + end # Holds a hash of header names and values. Accessed like headers["Cache-Control"] to get the value of the Cache-Control # directive. Values should always be specified as strings. @@ -787,7 +789,6 @@ module ActionController #:nodoc: # Resets the session by clearing out all the objects stored within and initializing a new session object. def reset_session #:doc: request.reset_session - @_session = request.session end private @@ -812,7 +813,7 @@ module ActionController #:nodoc: def assign_shortcuts(request, response) @_request, @_response, @_params = request, response, request.parameters - @_session, @_headers = @_request.session, @_response.headers + @_headers = @_response.headers end def initialize_current_url @@ -888,10 +889,6 @@ module ActionController #:nodoc: "#{request.protocol}#{request.host}#{request.request_uri}" end - def close_session - # @_session.close if @_session && @_session.respond_to?(:close) - end - def default_template(action_name = self.action_name) self.view_paths.find_template(default_template_name(action_name), default_template_format) end @@ -915,7 +912,6 @@ module ActionController #:nodoc: end def process_cleanup - close_session end end diff --git a/actionpack/lib/action_controller/testing/process.rb b/actionpack/lib/action_controller/testing/process.rb index c532a67e78..d073d06b19 100644 --- a/actionpack/lib/action_controller/testing/process.rb +++ b/actionpack/lib/action_controller/testing/process.rb @@ -165,7 +165,7 @@ module ActionController #:nodoc: # A shortcut to the flash. Returns an empty hash if no session flash exists. def flash - session['flash'] || {} + request.session['flash'] || {} end # Do we have a flash? diff --git a/actionpack/lib/action_dispatch/http/request.rb b/actionpack/lib/action_dispatch/http/request.rb index 0b8909ced7..2602b344ca 100755 --- a/actionpack/lib/action_dispatch/http/request.rb +++ b/actionpack/lib/action_dispatch/http/request.rb @@ -451,14 +451,6 @@ EOM @env['rack.input'] end - def session - @env['rack.session'] - end - - def session_options - @env['rack.session.options'] - end - def reset_session self.session_options.delete(:id) self.session = {} diff --git a/actionpack/lib/action_dispatch/http/response.rb b/actionpack/lib/action_dispatch/http/response.rb index 6c92fb9713..ebba4eefa0 100644 --- a/actionpack/lib/action_dispatch/http/response.rb +++ b/actionpack/lib/action_dispatch/http/response.rb @@ -40,7 +40,11 @@ module ActionDispatch # :nodoc: attr_writer :header alias_method :headers=, :header= - delegate :session, :to => :request + def session + ActiveSupport::Deprecation.warn("response.session has been deprecated. Use request.session instead", caller) + request.session + end + delegate :default_charset, :to => 'ActionController::Base' def initialize -- cgit v1.2.3