Borges in Apache not work in my case

Hello,

The following code doesn’t work in Apache, but works in Webrick.
In Apache, after pressing any button on page I got this page:

Exception in #: undefined method call' for nil /home/radek/opt/ruby-1.8.0-2003.05.22/lib/ruby/site_ruby/1.8/borges/Renderer.rb:126:inprocess_callbacks’ /home/radek/opt/ruby-1.8.0-2003.05.22/lib/ruby/site_ruby/1.8/borges/Renderer.rb:126:in each' /home/radek/opt/ruby-1.8.0-2003.05.22/lib/ruby/site_ruby/1.8/borges/Renderer.rb:126:inprocess_callbacks’ /home/radek/opt/ruby-1.8.0-2003.05.22/lib/ruby/site_ruby/1.8/borges/Renderer.rb:20:in render_response' /home/radek/opt/ruby-1.8.0-2003.05.22/lib/ruby/site_ruby/1.8/borges/Renderer.rb:6:inrender’ /home/radek/opt/ruby-1.8.0-2003.05.22/lib/ruby/site_ruby/1.8/borges/Page.rb:31:in response_loop' /home/radek/opt/ruby-1.8.0-2003.05.22/lib/ruby/site_ruby/1.8/borges/Page.rb:31:inloop’ /home/radek/opt/ruby-1.8.0-2003.05.22/lib/ruby/site_ruby/1.8/borges/Page.rb:31:in response_loop' /home/radek/opt/ruby-1.8.0-2003.05.22/lib/ruby/site_ruby/1.8/borges/Page.rb:24:ingo’ /home/radek/opt/ruby-1.8.0-2003.05.22/lib/ruby/site_ruby/1.8/borges/Page.rb:24:in callcc' /home/radek/opt/ruby-1.8.0-2003.05.22/lib/ruby/site_ruby/1.8/borges/Page.rb:24:ingo’ /home/radek/opt/ruby-1.8.0-2003.05.22/lib/ruby/site_ruby/1.8/borges/Page.rb:16:in call' /home/radek/opt/ruby-1.8.0-2003.05.22/lib/ruby/site_ruby/1.8/borges/Session.rb:118:inunknown_request’ /home/radek/opt/ruby-1.8.0-2003.05.22/lib/ruby/site_ruby/1.8/borges/Session.rb:108:in handle_request_intern' /home/radek/opt/ruby-1.8.0-2003.05.22/lib/ruby/site_ruby/1.8/borges/Session.rb:101:incallcc’ /home/radek/opt/ruby-1.8.0-2003.05.22/lib/ruby/site_ruby/1.8/borges/Session.rb:110:in handle_request_intern' /home/radek/opt/ruby-1.8.0-2003.05.22/lib/ruby/site_ruby/1.8/borges/Session.rb:43:ininitialize’ /home/radek/opt/ruby-1.8.0-2003.05.22/lib/ruby/site_ruby/1.8/borges/Session.rb:42:in synchronize' /home/radek/opt/ruby-1.8.0-2003.05.22/lib/ruby/site_ruby/1.8/borges/Session.rb:42:ininitialize’ /home/radek/opt/ruby-1.8.0-2003.05.22/lib/ruby/site_ruby/1.8/borges/Session.rb:41:in loop' /home/radek/opt/ruby-1.8.0-2003.05.22/lib/ruby/site_ruby/1.8/borges/Session.rb:47:ininitialize’ /home/radek/opt/ruby-1.8.0-2003.05.22/lib/ruby/site_ruby/1.8/borges/Session.rb:35:in start' /home/radek/opt/ruby-1.8.0-2003.05.22/lib/ruby/site_ruby/1.8/borges/Session.rb:35:ininitialize’ /home/radek/opt/ruby-1.8.0-2003.05.22/lib/ruby/site_ruby/1.8/borges/Application.rb:93:in new' /home/radek/opt/ruby-1.8.0-2003.05.22/lib/ruby/site_ruby/1.8/borges/Application.rb:93:innew_session’ /home/radek/opt/ruby-1.8.0-2003.05.22/lib/ruby/site_ruby/1.8/borges/Application.rb:83:in handle_request' /home/radek/opt/ruby-1.8.0-2003.05.22/lib/ruby/site_ruby/1.8/borges/Application.rb:43:inhandle_request’ /home/radek/opt/ruby-1.8.0-2003.05.22/lib/ruby/site_ruby/1.8/borges/ApacheDRbServer.rb:30:in handle_request' /home/radek/opt/ruby-1.8.0-2003.05.22/lib/ruby/site_ruby/1.8/drb/drb.rb:688:insend’ /home/radek/opt/ruby-1.8.0-2003.05.22/lib/ruby/site_ruby/1.8/drb/drb.rb:688:in perform_without_block' /home/radek/opt/ruby-1.8.0-2003.05.22/lib/ruby/site_ruby/1.8/drb/drb.rb:652:inperform’ /home/radek/opt/ruby-1.8.0-2003.05.22/lib/ruby/site_ruby/1.8/drb/drb.rb:761:in main_loop' /home/radek/opt/ruby-1.8.0-2003.05.22/lib/ruby/site_ruby/1.8/drb/drb.rb:757:inloop’ /home/radek/opt/ruby-1.8.0-2003.05.22/lib/ruby/site_ruby/1.8/drb/drb.rb:775:in main_loop' /home/radek/opt/ruby-1.8.0-2003.05.22/lib/ruby/site_ruby/1.8/drb/drb.rb:753:instart’ /home/radek/opt/ruby-1.8.0-2003.05.22/lib/ruby/site_ruby/1.8/drb/drb.rb:753:in main_loop' /home/radek/opt/ruby-1.8.0-2003.05.22/lib/ruby/site_ruby/1.8/drb/drb.rb:599:inrun’ /home/radek/opt/ruby-1.8.0-2003.05.22/lib/ruby/site_ruby/1.8/drb/drb.rb:596:in start' /home/radek/opt/ruby-1.8.0-2003.05.22/lib/ruby/site_ruby/1.8/drb/drb.rb:596:inrun’ /home/radek/opt/ruby-1.8.0-2003.05.22/lib/ruby/site_ruby/1.8/drb/drb.rb:549:in initialize' /home/radek/opt/ruby-1.8.0-2003.05.22/lib/ruby/site_ruby/1.8/drb/drb.rb:783:innew’ /home/radek/opt/ruby-1.8.0-2003.05.22/lib/ruby/site_ruby/1.8/drb/drb.rb:783:in start_service' /home/radek/opt/ruby-1.8.0-2003.05.22/lib/ruby/site_ruby/1.8/borges/ApacheDRbServer.rb:14:instart’ ./kontejner_srv.rb:11

The source is:
#!/usr/bin/env ruby

$Header: /home/radek/cvs/mpress-kontejnery/kontejner.rb,v 1.1.1.1 2003/05/22 10:03:46 radek Exp $

Databáze kontejnerů na barvu.

Copyright © 2003 Radek Hnilica

require 'borges’
require 'borges/Page’
require 'dbi’
include Borges

class Kontejner < Page
attr_reader :username

def initialize
end

def render_on(r)
r.table({'frame'=>'border', 'rules'=>'all'}) do
    # Table headers
    r.tr do
	r.print "<th>Kontejner</th><th>přijat</th>"
    end
    #render_table_buttons(r)
    DBI.connect('DBI:pg:kontejner:localhost', 'kontejner', 'XXXXXXXX') do |dbh|
	dbh.select_all(<<-EndOfSQL
		       SELECT kontejner_id, prijato
		       FROM kontejner
		       ORDER BY kontejner_id;
		       EndOfSQL
		       ) do |row|
	    r.tr do
		id,pri = row
		r.print <<-EOF
		<td>#{id}</td>
		<td>#{pri}</td>
		EOF
		# Line Buttons
		r.td do
		    r.form do
			r.submit({'value'=>'Del'})
		    end
		end
	    end
	end
    end
    r.tr do
	r.form do
	    id = pri = nil
	    r.td{r.text_input(''){|id|}}
	    r.td{r.text_input(''){|pri|}}
	    r.td{r.submit({'value'=>'Add'}){}}
	end
    end
end
end

def render_line_buttons(r)
end

def render_table_buttons(r)
r.tr do
    r.form do
	id = pri = nil
	r.td{r.text_input(''){|id|}}
	r.td{r.text_input(''){|pri|}}
	r.td{r.submit({'value'=>'Add'}){add_kontejner(id,pri)}}
    end
end
end

def add_kontejner(id, pri)
puts "add_kontejner(#{id}, #{pri})"
#DBI.connect('DBI:pg:kontejner:localhost', 'kontejner',  'XXXXXXXX') do |dbh|
#    dbh.do <<-EndOfSQL
#    INSERT INTO kontejner (kontejner_id, prijato)
#    VALUES ('#{id}', '#{pri}');
#    EndOfSQL
#end
end

end

if $0 == FILE then
require 'borges/Webrick’
Borges::register_application(“kontejner”, Kontejner)
Borges::WebrickConnection.start({:Port=>7777})
end

#Keep this comment at the end of the file
#Local variables:
#End:

It’s based on code published on
http://www.penguin.cz/~radek/book/borges/index.html

The apache is 1.3.26-0woody3, ruby the latest from cvs so borges.

···


Radek Hnilica

No matter how far down the wrong road you’ve gone, turn back.
Turkish proverb

I traced the things to this point.

There is some difference in request while calling process_callbacks.
Using Webrick there is parameter
@fileds={“4”=>“Del”}
While using Apache+DRb that parameter has form
@fileds="&5=Del"

So there is some incompatibility in way Apache and Webrick builds request.

···


Radek Hnilica

No matter how far down the wrong road you’ve gone, turn back.
Turkish proverb