Changeset 3806
- Timestamp:
- 03/07/06 04:42:13 (3 years ago)
- Files:
-
- trunk/actionpack/CHANGELOG (modified) (1 diff)
- trunk/actionpack/lib/action_controller/base.rb (modified) (2 diffs)
- trunk/actionpack/lib/action_controller/cgi_ext/cgi_methods.rb (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/actionpack/CHANGELOG
r3777 r3806 1 1 *SVN* 2 2 3 * Added new infrastructure support for REST webservices. 4 By default application/xml posts are handled by creating a XmlNode object with the same name as the root element of the submitted xml. More handlers can easily be registered like this 5 6 ActionController::Base.param_parsers['application/atom+xml'] = Proc.new do |data| 7 node = REXML::Document.new(post) 8 { node.root.name => node.root } 9 end 3 * Added plugin support for parameter parsers, which allows for better support for REST web services. By default, posts submitted with the application/xml content type is handled by creating a XmlSimple hash with the same name as the root element of the submitted xml. More handlers can easily be registered like this: 4 5 # Assign a new param parser to a new content type 6 ActionController::Base.param_parsers['application/atom+xml'] = Proc.new do |data| 7 node = REXML::Document.new(post) 8 { node.root.name => node.root } 9 end 10 11 # Assign the default XmlSimple to a new content type 12 ActionController::Base.param_parsers['application/backpack+xml'] = :xml_simple 10 13 11 XmlSimple and Yaml web services were retired, ActionController::Base.param_parsers carries an example which shows how to get this functionality back. 12 request.[formatted_post?, xml_post?, yaml_post? and post_format] were all deprecated in favor of request.content_type [Tobias Luetke] 14 Default YAML web services were retired, ActionController::Base.param_parsers carries an example which shows how to get this functionality back. As part of this new plugin support, request.[formatted_post?, xml_post?, yaml_post? and post_format] were all deprecated in favor of request.content_type [Tobias Luetke] 13 15 14 16 * Fixed Effect.Appear in effects.js to work with floats in Safari #3524, #3813, #3044 [Thomas Fuchs] trunk/actionpack/lib/action_controller/base.rb
r3782 r3806 265 265 # @params hash. These handlers are invoked for post and put requests. 266 266 # 267 # By default application/xml is enabled. a XmlNode class with the same param name as the root 268 # will be instanciated in the @params. 267 # By default application/xml is enabled. A XmlSimple class with the same param name as the root 268 # will be instanciated in the @params. This allows XML requests to mask themselves as regular form submissions, 269 # so you can have one action serve both regular forms and web service requests. 269 270 # 270 # Example :271 # Example of doing your own parser for a custom content type: 271 272 # 272 273 # ActionController::Base.param_parsers['application/atom+xml'] = Proc.new do |data| … … 275 276 # end 276 277 # 277 # Note: Up until release 1.1 rails would default to using XmlSimple for such requests. To get the old 278 # behavior you can re-register XmlSimple as application/xml handler and enable application/x-yaml like 279 # this: 278 # Note: Up until release 1.1 of Rails, Action Controller would default to using XmlSimple configured to discard the 279 # root node for such requests. The new default is to keep the root, such that "<r><name>David</name></r>" results 280 # in params[:r][:name] for "David" instead of params[:name]. To get the old behavior, you can 281 # re-register XmlSimple as application/xml handler and enable application/x-yaml like this: 280 282 # 281 # ActionController::Base.param_parsers['application/xml'] = :xml_simple 283 # ActionController::Base.param_parsers['application/xml'] = 284 # Proc.new { |data| XmlSimple.xml_in(data, 'ForceArray' => false) } 282 285 # ActionController::Base.param_parsers['application/x-yaml'] = :yaml 283 # 284 @@param_parsers = { 'application/xml' => :xml_node } 286 @@param_parsers = { 'application/xml' => :xml_simple } 285 287 cattr_accessor :param_parsers 286 288 trunk/actionpack/lib/action_controller/cgi_ext/cgi_methods.rb
r3778 r3806 61 61 def self.parse_formatted_request_parameters(format, raw_post_data) 62 62 params = case strategy = ActionController::Base.param_parsers[format] 63 when Proc64 strategy.call(raw_post_data)65 when :xml_node66 node = XmlNode.from_xml(raw_post_data)67 { node.node_name => node }68 when :xml_simple69 XmlSimple.xml_in(raw_post_data, 'ForceArray' => false)70 when :yaml71 YAML.load(raw_post_data)63 when Proc 64 strategy.call(raw_post_data) 65 when :xml_simple 66 XmlSimple.xml_in(raw_post_data, 'ForceArray' => false, :keeproot => true) 67 when :yaml 68 YAML.load(raw_post_data) 69 when :xml_node 70 node = XmlNode.from_xml(raw_post_data) 71 { node.node_name => node } 72 72 end 73 73