Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion Params in Before filter
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Konstantin Haase  
View profile  
 More options Jan 4 2011, 7:26 am
From: Konstantin Haase <k.ha...@finn.de>
Date: Tue, 4 Jan 2011 13:26:46 +0100
Local: Tues, Jan 4 2011 7:26 am
Subject: Re: Params in Before filter
It took me some time to understand what you think the issue is.

The main  issue is the concept behind Sinatra routing. You do not have one true params hash but different versions of that hash depending on the handler you're in.

This is how I see Sinatra routing: Prepare request, run a couple of handlers, generate response. Each handler has its own params hash, access to all helper methods and can set the response with methods like body or halt. There are special handlers that can also set the response with its return value (route handlers, error handlers), but otherwise handlers all have the same options available and only are different in when they are triggered. An incoming request is "falling" through this handlers, similar to a petri net, and triggered handlers have tools available to change the course the request takes (pass, modifying the request, etc). This is unique to Sinatra and no other Rack router I know of works that way, not even the Padrino router.

Therefore path patterns, like conditions, are criteria for triggering the specific handlers, passing those upfront would not only not fit this basic principal, but would also be a major performance impact. All incoming requests would have to be matched against all route handlers, the routing best case would be worse than the current worst case, since we would also have to check if the request patch changed after each handler and would have to reroute again. We would have to completely change the way we handle params, and all that without a use case. Or at least I'm not aware of one.

Konstantin

On Jan 4, 2011, at 04:25 , Matt Todd wrote:

> I recently was "troubled" with upgrading an older Sinatra app to a
> newer version that doesn't include route params in filters. I'd known
> about this "bug" but hadn't taken the time to address it until now.

> I found this old conversation that addressed my question: http://bit.ly/fOFwMC
> (Linking because I don't know if Google will relate these
> conversations since I'm not replying directly.)

> However, it doesn't answer if this SHOULD be the case or if it's just
> an unintended consequence of when the routing happens in relation to
> the filters.

> Obviously, having `pass` essentially say "this route is incorrect"
> makes this a little less trivial since it's unclear as to whether we
> should rerun the filters or not if we did perform routing before the
> filters. I am still not sure it makes more sense to duplicate routing
> patterns and explicit param extraction in the filtering, though.

> Is there an openly discussed opinion or decision somewhere that says
> that this is how it should be?

> Wrote a quick failing spec to make sure I wasn't crazy:
> https://gist.github.com/764340

> If anything perhaps we should add a spec that says "route params are
> NOT available in filters"? Make it part of the spec?

> Cheers,
> Matt

> --
> You received this message because you are subscribed to the Google Groups "sinatrarb" group.
> To post to this group, send email to sinatrarb@googlegroups.com.
> To unsubscribe from this group, send email to sinatrarb+unsubscribe@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/sinatrarb?hl=en.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.