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:in
process_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:in
process_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:in
render’ /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:in
loop’ /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:in
go’ /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:in
go’ /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:in
unknown_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:in
callcc’ /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:in
initialize’ /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:in
initialize’ /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:in
initialize’ /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:in
initialize’ /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:in
new_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:in
handle_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:in
send’ /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:in
perform’ /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:in
loop’ /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:in
start’ /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:in
run’ /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:in
run’ /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:in
new’ /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:in
start’ ./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