From khaines at enigo.com Mon Nov 22 12:24:29 2004 From: khaines at enigo.com (Kirk Haines) Date: Mon Nov 22 12:17:41 2004 Subject: [Kansas-general] Re: Kansas-general subscription notification In-Reply-To: References: Message-ID: <20041122172321.M31423@enigo.com> Welcome to the list, Reid Thompson. Let me know how I can help you. Kirk Haines From khaines at enigo.com Mon Nov 22 17:28:07 2004 From: khaines at enigo.com (Kirk Haines) Date: Mon Nov 22 17:21:14 2004 Subject: [Kansas-general] Re: Kansas-general subscription notification In-Reply-To: References: Message-ID: <20041122222528.M86309@enigo.com> On Mon, 22 Nov 2004 12:42:27 -0500, Reid Thompson wrote > to date, i've hacked around a little in the examples and i've > successfully started a webrick app with a dbpool and kansas to > postgresql -- now to look through the kansas tutorial to understand how > to utilize the connection(s). Great! There is also a seperate IOWA mailing list, and there's an IRC channel on freenode.net, #IOWA, that I monitor most of my waking hours. The scope of #IOWA covers Kansas, too, BTW. Both IOWA and Kansas docs are currently in the middle of some much needed rewriting. I am glad to see that you have gotten webrick with kansas and postgresql connections going, though. That's a freat start. Thanks, Kirk Haines From Reid.Thompson at ateb.com Mon Nov 29 10:32:20 2004 From: Reid.Thompson at ateb.com (Reid Thompson) Date: Mon Nov 29 10:31:41 2004 Subject: [Kansas-general] Iowa/Kansas/Primary Key/Object dereference questions Message-ID: an initial learning exercise with iowa and kansas pgsql -- assume i.... create table myusers(username text, userpassword text); create unique index idx_uniq_myusers on myusers(username, userpassword); //so that there can only be unique rows for the select shown below insert into myusers('rthompso', 'rthompso'); so i have a two column table populated with one row. Question 1: in Main.iwa i.... def myresult auser = nil application.dbpool.getConnection do |ksdbh| auser = ksdbh.select(:Myusers){|user| (user.username == 'rthompso') & (user.userpassword == 'rthompso'} end auser[0].username end end and in Main.html i.... Hello World!

Hello World!

@myresult myresult fails --> It will only work if I create the table myusers with a primary key. Are primary keys on tables a requirement for kansas (or one of the parent classes)? I can see that the select is being properly made to the database via postgresql's log. The output of the failure is listed at the bottom of the email(both the output to the webpage and the log entry). Question 2: if i alter myresult to... def myresult auser = nil application.dbpool.getConnection do |ksdbh| auser = ksdbh.select(:Myusers){|user| (user.username == 'rthompso') & (user.userpassword == 'rthompso'} end auser end end is it possible to (de)reference the auser object in Main.html some way...ala... Hello World!

Hello World!

@myresult[0].username thanks, reid output to the webpage referenced from Question 1: Hello World! undefined method `collect' for nil:NilClass /lib/ruby/site_ruby/kansas/Table.rb:49:in `key' /lib/ruby/site_ruby/kansas/Database.rb:480:in `add_object' /lib/ruby/site_ruby/kansas/Database.rb:231:in `select' /lib/ruby/site_ruby/kansas/Database.rb:230:in `fetch' /lib/ruby/site_ruby/1.8/dbi/dbi.rb:836:in `each' /lib/ruby/site_ruby/1.8/dbi/dbi.rb:664:in `select_all' /lib/ruby/site_ruby/1.8/dbi/dbi.rb:662:in `execute' /lib/ruby/site_ruby/1.8/dbi/dbi.rb:662:in `select_all' /lib/ruby/site_ruby/kansas/Database.rb:230:in `select' (eval):22:in `myresult' (eval):21:in `getConnection' (eval):21:in `myresult' /lib/ruby/site_ruby/iowa/KeyValueCoding.rb:9:in `__send__' /lib/ruby/site_ruby/iowa/KeyValueCoding.rb:9:in `valueForKey' /lib/ruby/site_ruby/iowa/KeyValueCoding.rb:31:in `valueForKeyPath' /lib/ruby/site_ruby/iowa/KeyValueCoding.rb:25:in `each_index' /lib/ruby/site_ruby/iowa/KeyValueCoding.rb:25:in `valueForKeyPath' /lib/ruby/site_ruby/iowa/Association.rb:13:in `get' /lib/ruby/site_ruby/iowa/Context.rb:96:in `getBinding' /lib/ruby/site_ruby/iowa/DynamicElements.rb:42:in `handleResponse' /lib/ruby/site_ruby/iowa/Element.rb:72:in `__send__' /lib/ruby/site_ruby/iowa/Element.rb:72:in `handleChildren' /lib/ruby/site_ruby/iowa/Element.rb:70:in `each' /lib/ruby/site_ruby/iowa/Element.rb:70:in `handleChildren' /lib/ruby/site_ruby/iowa/Element.rb:78:in `handleRequestOrResponse' /lib/ruby/site_ruby/iowa/Element.rb:86:in `handleResponse' /lib/ruby/site_ruby/iowa/Component.rb:131:in `__send__' /lib/ruby/site_ruby/iowa/Component.rb:131:in `handleRequestOrResponse' /lib/ruby/site_ruby/iowa/Component.rb:120:in `handleResponse' /lib/ruby/site_ruby/iowa/Session.rb:169:in `handleResponse' /lib/ruby/site_ruby/iowa/Session.rb:152:in `handleRequest' /lib/ruby/site_ruby/iowa/Session.rb:121:in `synchronize' /lib/ruby/site_ruby/iowa/Session.rb:121:in `handleRequest' /lib/ruby/site_ruby/iowa/Application.rb:146:in `handleRequest' /lib/ruby/site_ruby/iowa/WEBrickServlet.rb:59:in `do_GET' /lib/ruby/site_ruby/iowa/WEBrickServlet.rb:56:in `catch' /lib/ruby/site_ruby/iowa/WEBrickServlet.rb:56:in `do_GET' /lib/ruby/1.8/webrick/httpservlet/abstract.rb:35:in `__send__' /lib/ruby/1.8/webrick/httpservlet/abstract.rb:35:in `service' /lib/ruby/site_ruby/iowa/HTTPServer.rb:66:in `service' /lib/ruby/1.8/webrick/httpserver.rb:54:in `run' /lib/ruby/1.8/webrick/server.rb:150:in `start_thread' /lib/ruby/1.8/webrick/server.rb:144:in `start' /lib/ruby/1.8/webrick/server.rb:144:in `start_thread' /lib/ruby/1.8/webrick/server.rb:94:in `start' /lib/ruby/1.8/webrick/server.rb:89:in `each' /lib/ruby/1.8/webrick/server.rb:89:in `start' /lib/ruby/1.8/webrick/server.rb:79:in `start' /lib/ruby/1.8/webrick/server.rb:79:in `start' /lib/ruby/site_ruby/iowa_webrick.rb:65:in `run' startup_template.rb:61 Log entry referenced in Question 1: [WARN] iowa_log @ 2004-11-29 10:28:54 :: Execution Error: undefined method `collect' for nil:NilClass :: /lib/ruby/site_ruby/kansas/Table.rb:49:in `key'...../lib/ruby/site_ruby/kansas/Database.rb:480:in `add_object'...../lib/ruby/site_ruby/kansas/Database.rb:231:in `select'...../lib/ruby/site_ruby/kansas/Database.rb:230:in `fetch'...../lib/ruby/site_ruby/1.8/dbi/dbi.rb:836:in `each'...../lib/ruby/site_ruby/1.8/dbi/dbi.rb:664:in `select_all'...../lib/ruby/site_ruby/1.8/dbi/dbi.rb:662:in `execute'...../lib/ruby/site_ruby/1.8/dbi/dbi.rb:662:in `select_all'...../lib/ruby/site_ruby/kansas/Database.rb:230:in `select'.....(eval):22:in `myresult'.....(eval):21:in `getConnection'.....(eval):21:in `myresult'...../lib/ruby/site_ruby/iowa/KeyValueCoding.rb:9:in `__send__'...../lib/ruby/site_ruby/iowa/KeyValueCoding.rb:9:in `valueForKey'...../lib/ruby/site_ruby/iowa/KeyValueCoding.rb:31:in `valueForKeyPath'...../lib/ruby/site_ruby/iowa/KeyValueCoding.rb:25:in `each_index'...../lib/ruby/site_ruby/iowa/KeyValueCoding.rb:25:in `valueForKeyPath'...../lib/ruby/site_ruby/iowa/Association.rb:13:in `get'...../lib/ruby/site_ruby/iowa/Context.rb:96:in `getBinding'...../lib/ruby/site_ruby/iowa/DynamicElements.rb:42:in `handleResponse'...../lib/ruby/site_ruby/iowa/Element.rb:72:in `__send__'...../lib/ruby/site_ruby/iowa/Element.rb:72:in `handleChildren'...../lib/ruby/site_ruby/iowa/Element.rb:70:in `each'...../lib/ruby/site_ruby/iowa/Element.rb:70:in `handleChildren'...../lib/ruby/site_ruby/iowa/Element.rb:78:in `handleRequestOrResponse'...../lib/ruby/site_ruby/iowa/Element.rb:86:in `handleResponse'...../lib/ruby/site_ruby/iowa/Component.rb:131:in `__send__'...../lib/ruby/site_ruby/iowa/Component.rb:131:in `handleRequestOrResponse'...../lib/ruby/site_ruby/iowa/Component.rb:120: in `handleResponse'...../lib/ruby/site_ruby/iowa/Session.rb:169:in `handleResponse'...../lib/ruby/site_ruby/iowa/Session.rb:152:in `handleRequest'...../lib/ruby/site_ruby/iowa/Session.rb:121:in `synchronize'...../lib/ruby/site_ruby/iowa/Session.rb:121:in `handleRequest'...../lib/ruby/site_ruby/iowa/Application.rb:146:in `handleRequest'...../lib/ruby/site_ruby/iowa/WEBrickServlet.rb:59:in `do_GET'...../lib/ruby/site_ruby/iowa/WEBrickServlet.rb:56:in `catch'...../lib/ruby/site_ruby/iowa/WEBrickServlet.rb:56:in `do_GET'...../lib/ruby/1.8/webrick/httpservlet/abstract.rb:35:in `__send__'...../lib/ruby/1.8/webrick/httpservlet/abstract.rb:35:in `service'...../lib/ruby/site_ruby/iowa/HTTPServer.rb:66:in `service'...../lib/ruby/1.8/webrick/httpserver.rb:54:in `run'...../lib/ruby/1.8/webrick/server.rb:150:in `start_thread'...../lib/ruby/1.8/webrick/server.rb:144:in `start'...../lib/ruby/1.8/webrick/server.rb:144:in `start_thread'...../lib/ruby/1.8/webrick/server.rb:94:in `start'...../lib/ruby/1.8/webrick/server.rb:89:in `each'...../lib/ruby/1.8/webrick/server.rb:89:in `start'...../lib/ruby/1.8/webrick/server.rb:79:in `start'...../lib/ruby/1.8/webrick/server.rb:79:in `start'...../lib/ruby/site_ruby/iowa_webrick.rb:65:in `run'.....startup_template.rb:61 [INFO] iowa_log @ 2004-11-29 10:28:54 :: Mon Nov 29 10:28:54 GMT-5:00 2004 (0.0/0.0399999618530273) :: / EOUT 3174B [DEBUG] iowa_log @ 2004-11-29 10:28:54 :: close: 127.0.0.1:2775 [DEBUG] iowa_log @ 2004-11-29 10:28:54 :: accept: 127.0.0.1:2776 [ERROR] iowa_log @ 2004-11-29 10:28:54 :: Caught NameError: uninitialized constant Iowa::HTTPServer::HTTPStatus /lib/ruby/site_ruby/iowa/HTTPServer.rb:61:in `service' /lib/ruby/1.8/webrick/httpserver.rb:54:in `run' /lib/ruby/1.8/webrick/server.rb:150:in `start_thread' /lib/ruby/1.8/webrick/server.rb:144:in `start' /lib/ruby/1.8/webrick/server.rb:144:in `start_thread' /lib/ruby/1.8/webrick/server.rb:94:in `start' /lib/ruby/1.8/webrick/server.rb:89:in `each' [DEBUG] iowa_log @ 2004-11-29 10:28:54 :: close: 127.0.0.1:2776 From Reid.Thompson at ateb.com Mon Nov 29 13:09:20 2004 From: Reid.Thompson at ateb.com (Reid Thompson) Date: Mon Nov 29 13:12:13 2004 Subject: [Kansas-general] Caught NameError: uninitialized constant Iowa::HTTPServer::HTTPStat Message-ID: Could someone advise me as to what i'm missing in the below simple application that is causing this error: [INFO] iowa_log @ 2004-11-29 11:51:11 :: Logging subsystem initialized. [INFO] iowa_log @ 2004-11-29 11:51:11 :: Process forked and daemonized as PID 5044. [INFO] iowa_log @ 2004-11-29 11:51:12 :: Application with docroot of /C/rubytests/myiowa initialized. [INFO] iowa_log @ 2004-11-29 11:51:12 :: Creating WEBrick server on port 2000 with a document root of . The mapfile is at mapfile.config, and the Ruby interpreter used for CGI programs is /bin/ruby.exe. [INFO] iowa_log @ 2004-11-29 11:51:12 :: Loading template /C/rubytests/myiowa/Main.html [INFO] iowa_log @ 2004-11-29 11:51:12 :: Creating namespace Iowa::Application::Content_Classes [INFO] iowa_log @ 2004-11-29 11:51:12 :: Stuffing /C/rubytests/myiowa/Main.html into template cache [INFO] iowa_log @ 2004-11-29 11:51:12 :: WEBrick 1.3.1 [INFO] iowa_log @ 2004-11-29 11:51:12 :: ruby 1.8.1 (2003-12-25) [i386-cygwin] [DEBUG] iowa_log @ 2004-11-29 11:51:12 :: TCPServer.new(0.0.0.0, 2000) [INFO] iowa_log @ 2004-11-29 11:51:12 :: Starting WEBrick... [INFO] iowa_log @ 2004-11-29 11:51:12 :: Iowa::HTTPServer#start: pid=5044 port=2000 [DEBUG] iowa_log @ 2004-11-29 11:51:24 :: accept: 127.0.0.1:3168 [DEBUG] iowa_log @ 2004-11-29 11:51:24 :: Iowa::WEBrickServlet is invoked. [INFO] iowa_log @ 2004-11-29 11:51:24 :: Mon Nov 29 11:51:24 GMT-5:00 2004 (0.0/0.0410001277923584) :: / OK 200B [DEBUG] iowa_log @ 2004-11-29 11:51:24 :: close: 127.0.0.1:3168 [DEBUG] iowa_log @ 2004-11-29 11:51:24 :: accept: 127.0.0.1:3169 [ERROR] iowa_log @ 2004-11-29 11:51:24 :: Caught NameError: uninitialized constant Iowa::HTTPServer::HTTPStatus /lib/ruby/site_ruby/iowa/HTTPServer.rb:61:in `service' /lib/ruby/1.8/webrick/httpserver.rb:54:in `run' /lib/ruby/1.8/webrick/server.rb:150:in `start_thread' /lib/ruby/1.8/webrick/server.rb:144:in `start' /lib/ruby/1.8/webrick/server.rb:144:in `start_thread' /lib/ruby/1.8/webrick/server.rb:94:in `start' /lib/ruby/1.8/webrick/server.rb:89:in `each' [DEBUG] iowa_log @ 2004-11-29 11:51:24 :: close: 127.0.0.1:3169 >============================================= > Main.html >============================================= > > Hello World! >

Hello World!

> @current_time >
> @myresult >
> @theuser >
> @thepassword > > >============================================= > Main.iwa >============================================= > #require 'log4r' > #include Log4r > > class Main < Iowa::Component > > #mylog = Logger['iowa_log'] > #mylog.info('In Main.iwa') > > attr_accessor :theuser, :thepassword > > def current_time > Time.now.to_s > end > > def myresult > auser = nil > application.dbpool.getConnection do |ksdbh| > auser = ksdbh.select(:Myusers){|user| (user.username == > 'rthompso') & (user.userpassword == 'rthompso')} > end > @theuser = auser[0].username > @thepassword = auser[0].userpassword > auser[0].username > end > > end >============================================= > mapfile.config >============================================= > /: Main >============================================= > startup_template.config >============================================= > socket: > hostname: localhost > path: ../demo_socket > logging: > basedir: ../log > minlevel: 0 > maxsize: 10000000 > maxage: 86400 > webrick: > port: > docroot: > cgiprefix: > cgiroot: > >============================================= > startup_template.rb >============================================= > #!/usr/bin/ruby > > #require 'iowa' > require 'iowa_webrick' # Uncomment this line and comment the one above > to use Iowa + WEBrick. require 'iowa/DbPool' > require 'kansas' > > class MySession < Iowa::Session > > def initialize(*args) > > ##### > #// Setup some useful data sets for the components to use. > #// Page cache defaults to 10 pages. If you want more, > #// change @@cachedPages here. > ##### > > ##### > #// Invoke the superclass > ##### > super > end > end > > class MyApplication < Iowa::Application > > ##### > #// If you want to use the database connection pool, uncomment below. > ##### > > attr_accessor :dbpool > > def initialize(*args) > ##### > #// Uncomment below and change the connect information to use the > #// connection pool. > ##### > @dbpool = Iowa::DbPool.new('Pg','localhost','demodb','sigcap','sigcap',2 ,300) {|dbh| > ksdbh = KSDatabase.new(dbh) > begin > @@ks_done_init > rescue NameError > @@ks_done_init = true > ksdbh.map_all_tables > end > ksdbh > } > > ##### > #// Do whatever other setup is needed. Default session cache size > #// is 10. Change @@cachedSessions here to change that. > #### > @@cachedSessions = 1000 > @mapfile = 'mapfile.config' > super > end > end > > Iowa.startDaemon('startup_template.config') > Iowa.run From khaines at enigo.com Mon Nov 29 15:25:10 2004 From: khaines at enigo.com (khaines) Date: Mon Nov 29 15:34:31 2004 Subject: [Kansas-general] Caught NameError: uninitialized constant Iowa::HTTPServer::HTTPStat In-Reply-To: References: Message-ID: <20041129202000.M78277@enigo.com> On Mon, 29 Nov 2004 13:09:20 -0500, Reid Thompson wrote > Could someone advise me as to what i'm missing in the below simple > application that is causing this error: Just letting you know that I got this. I'm working off of a borrowed computer right now while waiting for Starband to fix my internet access.... The satellite my access goes through has quit talking. I'll drop this main to a floppy and take a look at it when I get home and can do some testing. Hopefully my access will be rerouted through another satellite soon. Otherwise, earliest I can have a response back to you is when I am back here tomorrow. Thanks, Kirk Haines BTW, there is an IOWA mailing list at rubyforge, too. iowa-general.