[Mongrel] Mongrel handler and root_handler

Emmanuel Pinault seatmanu at gmail.com
Fri May 30 19:35:09 EDT 2008


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


More information about the Mongrel-users mailing list