> AFAIK, Merb follows the same convention as well
It does, and +1 for this idea from me.
MK
Why shouldn't this be application-level behavior, or at least a Rack
plugin, rather than default, built-in behavior?
While this happens to be common behavior in most Ruby Web frameworks (I
believe Ramaze follows this as well) I'm leery of libs that make certain
assumptions about data.
--
James Britt
www.happycamperstudios.com - Wicked Cool Coding
www.jamesbritt.com - Playing with Better Toys
www.ruby-doc.org - Ruby Help & Documentation
www.rubystuff.com - The Ruby Store for Ruby Stuff
Parameters retrievable via symbols and strings is a right out no to
me. The issue of identity vs content. Also, how would you deal with
environments running with $SAFE > 0? Or are you talking about
stringifying all symbol key lookups, which creates additional overhead
as well as defeating the general point of symbol keyed hashes.
date/time parsing?
--
stadik.net
Indeed, there are issues with parsing that might not reach a consent.
(Ramaze/Innate) are actually reparsing Request#params with less than
stellar results in performance and a few divergences from the normal
(say PHP) behaviour.
I think it would be good to take a look at the existing
implementations, line them up and see which one is the fittest to make
a suitable middleware anybody can use.
The candidate I send into battle:
http://paste.linuxhelp.tv/pastes/view/15309
Due to its dependence on Rack::Request#params it might be less
performant than other solutions.
^ manveru
In rack core or contrib?
--
stadik.net
The feature seems sensible, but I would not want it to be the default
behavior for #params. I'm fine with having a seperate method for it,
or a method in Utils. And please specify exactly how it works! There
are so many details there to take care of.
--
Christian Neukirchen <chneuk...@gmail.com> http://chneukirchen.org
> I'm not a huge fan of adding more and more features to Rack::Request.
> The setting up of hashes in the params makes sense but adds the
> complication of a param value being a String, an Array, or a Hash. I'd
> vote yea due to the convenience it provides. With an 'eh' on parsing
> issues.
>
> Parameters retrievable via symbols and strings is a right out no to
> me. The issue of identity vs content.
+1
Also, I wonder how often people need *nested* hashes...
I think we had issues trying to override the default behavior without
having to do alot of work. Maybe this issue can be solved by a simple
refactoring?
What about sidestepping the issue by making Rack::Request call a
callback to do params parsing with the default callback being the
current implementation? Then any framework that wants its own parsing
can provide its own callback for params parsing?
This keeps it simple, does not break backwardas compat and solves all
of our issues with regards to how we want to do params parsing.
Cheers-
Ezra Zygmuntowicz
e...@engineyard.com
> Depending on how the callback is specified, it could be slower (for
> instance, if a proc was specified).
The fastest callback form is using #send. Unfortunately that requires
two objects to specify a callback. I've been considering wrapping up a
gem for this, as I'm starting to use callbacks more and more.
Some examples of what kind of API you end up with using either can be
found in:
http://github.com/raggi/thin/tree/async_for_rack/example # all proc
based stuff
and
http://github.com/raggi/object_protocol/ # All send based.
All of the above is somewhat experimental (particularly wrt api).
Another place that may have structures of interest, might be omnibus:
http://github.com/mental/concurrent/tree
Enjoy.
>
> -- Yehuda
Here are my suggestions:
1.) A config parameter that let's the Rack app decide which type of
parameter 'processing' it would like to use.
2.) An 'extended_params' method that returns the extra processed
parameters.
3.) A piece of Rack middleware in Rack-contrib that does the pre-
processing of the parameters, so it's only used if people put it in
line.
#3 is my favorite. It allows people to pick and chose which
implementation of parameter processing they want. If you use this
middleware then the params method returns a nested Hash that Rails,
Merb, and Mack users are already familiar with. If you don't use the
middleware, then you get back a straight, non-nested Hash.
#2 I'm not that big a fan of because, as a framework guy, I would know
to use that method, but people extending the framework wouldn't know
that, so it's possible for them to use the wrong method and cause
bugs. This method would most likely end up being aliased to params by
the frameworks to avoid this confusion.
#1 is alright, but a bit hacky. It would work, but if you want to add
a different type of processing then you would have to alter the
original Rack source, and that's uncool.
What do people think about #3? I think it solves all the problems.
-------------------------------------------------------------------------------------------------
Mark Bates
ma...@mackframework.com
http://www.mackframework.com
http://api.mackframework.com/
http://github.com/markbates/mack
On Dec 28, 2008, at 2:44 PM, Ezra Zygmuntowicz wrote:\
Ezra, I think the original idea was that if nearly every framework is doing the same thing, shouldn't that be default. Callbacks would have the same problem, every framework writing the same implementation of the same thing. With that said, I completely understand the other side of the argument.
Here are my suggestions:
1.) A config parameter that let's the Rack app decide which type of parameter 'processing' it would like to use.
2.) An 'extended_params' method that returns the extra processed parameters.
3.) A piece of Rack middleware in Rack-contrib that does the pre-processing of the parameters, so it's only used if people put it in line.
--
stadik.net
> Here are my suggestions:
>
> 1.) A config parameter that let's the Rack app decide which type of
> parameter 'processing' it would like to use.
> 2.) An 'extended_params' method that returns the extra processed
> parameters.
> 3.) A piece of Rack middleware in Rack-contrib that does the pre-
> processing of the parameters, so it's only used if people put it in
> line.
Does 3.) imply the parameters always are parsed?
--------
Mark Bates
On Dec 28, 2008, at 6:42 PM, Christian Neukirchen <chneuk...@gmail.com
> Hmm... Yeah. Good point. I didn't think about that. Back to the
> drawing board I guess.
I wonder if that really hurts... parsing query_string is quick, and
file uploads usually don't happen to arbitrary endpoints.
Also, it is possible for param parsing to be reasonably slow,
especially as more complex parameters are used.
I really want us to be in the habit of trying to avoid processing
things unless they are actually needed.
Sent from my iPhone
--------
Mark Bates
> I'm in favor of this, but others were concerned that it would be wasteful if
> not needed. I actually think that's speculative, since my recollection is that
> Merb's impl is basically the same speed if nested params are not used. I will
> confirm tomorrow.
>
> -- Yehuda
A good heuristic could be QUERY_STRING =~ /\[/.
Another thing: If we have foo[bar]=quux, should we return a hash like
{"foo" => {"bar" => "quux"},
"foo[bar]" => "quux"}
Then apps not knowing of this behavior can work as usual.
--
stadik.net
Please do not include this feature unless we decide it will replace the old one.
--
Joshua Peek