aboutsummaryrefslogtreecommitdiffstats
path: root/railties/lib/dispatcher.rb
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2005-02-15 01:24:55 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2005-02-15 01:24:55 +0000
commit88a3343ed57c01ca358da8473d15fc4d2b4a5bff (patch)
tree3fe773bb113480f68eaea508d241cbaf90eebfde /railties/lib/dispatcher.rb
parent60f7a5cab73fab032fdb73d1a9a8061cf20031d2 (diff)
downloadrails-88a3343ed57c01ca358da8473d15fc4d2b4a5bff.tar.gz
rails-88a3343ed57c01ca358da8473d15fc4d2b4a5bff.tar.bz2
rails-88a3343ed57c01ca358da8473d15fc4d2b4a5bff.zip
Backed out of routing merge.. investigating missing patches
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@616 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'railties/lib/dispatcher.rb')
-rw-r--r--railties/lib/dispatcher.rb52
1 files changed, 37 insertions, 15 deletions
diff --git a/railties/lib/dispatcher.rb b/railties/lib/dispatcher.rb
index 74de93713c..566b031295 100644
--- a/railties/lib/dispatcher.rb
+++ b/railties/lib/dispatcher.rb
@@ -24,34 +24,56 @@
require 'breakpoint'
class Dispatcher
- class << self
+ class <<self
def dispatch(cgi = CGI.new, session_options = ActionController::CgiRequest::DEFAULT_SESSION_OPTIONS)
begin
- prepare_application
- request, response = ActionController::CgiRequest.new(cgi, session_options), ActionController::CgiResponse.new(cgi)
- ActionController::Routing::Routes.recognize!(request).process(request, response).out
+ Breakpoint.activate_drb("druby://localhost:#{BREAKPOINT_SERVER_PORT}", nil, !defined?(FastCGI)) if defined?(BREAKPOINT_SERVER_PORT)
+
+ request = ActionController::CgiRequest.new(cgi, session_options)
+ response = ActionController::CgiResponse.new(cgi)
+
+ controller_name, module_name = controller_name(request.parameters), module_name(request.parameters)
+
+ require_or_load("application")
+ require_or_load(controller_path(controller_name, module_name))
+
+ controller_class(controller_name).process(request, response).out
rescue Object => exception
ActionController::Base.process_with_exception(request, response, exception).out
ensure
- reset_application
+ reset_application if Dependencies.load?
+ Breakpoint.deactivate_drb if defined?(BREAKPOINT_SERVER_PORT)
end
end
private
- def prepare_application
- ActionController::Routing::Routes.reload if Dependencies.load?
- Breakpoint.activate_drb("druby://localhost:#{BREAKPOINT_SERVER_PORT}", nil, !defined?(FastCGI)) if defined?(BREAKPOINT_SERVER_PORT)
- Controllers.const_load!("application") unless Controllers.const_defined?(:ApplicationController)
+ def reset_application
+ Dependencies.clear
+ Dependencies.remove_subclasses_for(ActiveRecord::Base, ActiveRecord::Observer, ActionController::Base)
end
- def reset_application
- if Dependencies.load?
- Controllers.clear
- Dependencies.clear
- Dependencies.remove_subclasses_for(ActiveRecord::Base, ActiveRecord::Observer, ActionController::Base)
+ def controller_path(controller_name, module_name = nil)
+ if module_name
+ "#{module_name}/#{controller_name.underscore}_controller"
+ else
+ "#{controller_name.underscore}_controller"
end
+ end
- Breakpoint.deactivate_drb if defined?(BREAKPOINT_SERVER_PORT)
+ def controller_class(controller_name)
+ Object.const_get(controller_class_name(controller_name))
+ end
+
+ def controller_class_name(controller_name)
+ "#{controller_name.camelize}Controller"
+ end
+
+ def controller_name(parameters)
+ parameters["controller"].downcase.gsub(/[^_a-zA-Z0-9]/, "").untaint
+ end
+
+ def module_name(parameters)
+ parameters["module"].downcase.gsub(/[^_a-zA-Z0-9]/, "").untaint if parameters["module"]
end
end
end \ No newline at end of file