Forum: Mongrel Mongrel handler and root_handler

77dae8923911b83d3d4e1fbb22d95cd8?d=identicon&s=25 Emmanuel Pinault (Guest)
on 2008-05-31 01:40
(Received via mailing list)
Hi

I am writing my own handler and seeing some strance behavior. Best is
describing by the following code

say I create mongrel server (see at the end of the email) and have one
handler for the root (so shoudl handle all request..)
To my surprise the @a in the following code in the Handlder is not the
object I expect but a hash containing the name  {:a => <SomeObject
Instance> }

Looking right before the register is called, @a is correct... but
looking inside the handler... suddenly it is all different...... I
cannot find any doc or why in the code it is behaving that way,..
I am supposing this something due to how mongrel works but cannot
figure out why

any help would be appreciated

Thanks

Manu

class MyServer
  def initialize( ip, port, log ,etc..)
    //saving all param in internal attributes
    ...

    @a = SomeObject.new
  end

  def start

    server = Mongrel::HttpServer.new('localhost',  'port')
    server.register("/", MyHandler.new(@a)
  end
end

Following is the handler code

class Myhandler < Mongrel::HttpHandler
  def initialize(a, b, c)
    @a = a
  end

  def process(request, response)
    // some code...

    @a = > this is a hash and not the real object passed originally
  end
end
This topic is locked and can not be replied to.