On Feb 16, 2:48 am, Stephen Eley <[email protected]> wrote:
> On Sun, Feb 15, 2009 at 9:06 AM, MarkMT <[email protected]> wrote:
>
> > I'm having trouble seeing what 'request' in this method definition
> > refers to. It appears to be an object of class Merb::Request, or a
> > method returning such an object (since the Request class defines a
> > 'session' method), but I haven't been able to find where that object
> > or method is defined. No doubt I'm missing something obvious, but it
> > has eluded me so far. Can someone tell me what that object refers to?
>
> You got it. Merb::Request is a basic core class, and it's initialized
> at the very bottom of the Merb call stack -- in the "call" method of
> merb-core/rack/application.rb in fact. "call" is the generic method
> that Rack uses to invoke application code, and Merb::Request just
> takes the HTTP request data passed to it by Rack and puts some useful
> access methods around it.
Thanks Steve. I think you're referring to this -
----
module Merb
module Rack
class Application
def call(env)
begin
rack_response = ::Merb::Dispatcher.handle(Merb::Request.new
(env))
rescue Object => e
return [500, {Merb::Const::CONTENT_TYPE =>
Merb::Const::TEXT_SLASH_HTML}, e.message + Merb::Const::BREAK_TAG +
e.backtrace.join(Merb::Const::BREAK_TAG)]
end
Merb.logger.info Merb::Const::DOUBLE_NEWLINE
Merb.logger.flush
rack_response
end
----
Is that correct? I had seen that, but I'm still puzzled about how the
'Merb::Request.new(env)' object that is created here is subsequently
accessed as 'request' from within the controller (e.g. in the
'session' method of Merb:SessionMixin).
There is a 'request' variable in ::Merb::Dispatcher.handle but it's
local to that method. And I don't see any another 'request' method in
scope that provides access to the object. Maybe I'm running into the
limitations of my Ruby knowledge. I'm sure the answer is
straightforward, but I'm just not seeing it.
Would appreciate any further guidance.
>
> If you want to see this in action yourself, one easy way is to
> intentionally throw a runtime error into your Merb code (try
> misspelling "form_for" for instance, it's loads of fun) and then
> select the "All" checkbox in the stack trace. Then click errors and
> read the whole call stack to your heart's content. It's a fast-paced
> narrative, with lots of twists and turns. I won't give away the
> ending for you. (But if Kevin Spacey's in your app, it's a good bet
> he's the bad guy... Oops.)
>
> --
> Have Fun,
> Steve Eley ([email protected])
> ESCAPE POD - The Science Fiction Podcast Magazine
> http://www.escapepod.org
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"merb" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [email protected]
For more options, visit this group at http://groups.google.com/group/merb?hl=en
-~----------~----~----~----~------~----~------~--~---