There is a very long thread [ruby-talk:39898] that talks about changes
in the CGI api to make cgiobj[“someval”] return a string instead of array
and have cgiobj.params(“someval”) return an array. Did any of these changes
ever get applied? I’ve looked on the RAA for newer versions of cgi.rb, but I’m
assuming it’s only bundled with Ruby. I would love to get away from doing
cgiobj[“someval”].to_s so hopefully some headway has been made in this
direction.
On Friday 17 January 2003 04:48 pm, Travis Whitton wrote:
There is a very long thread [ruby-talk:39898] that talks about changes
in the CGI api to make cgiobj[“someval”] return a string instead of array
and have cgiobj.params(“someval”) return an array. Did any of these changes
ever get applied? I’ve looked on the RAA for newer versions of cgi.rb, but
I’m assuming it’s only bundled with Ruby. I would love to get away from
doing cgiobj[“someval”].to_s so hopefully some headway has been made in
this direction.
I was wondering where I could post such a modification so that others could
use it as well. It seems a bit silly to post a 10 line hack to the RAA.
Is there a page on the Wiki that would be appropriate?
You’re damn right there is. StandardClassExceptions is the place.
Create a page StandardClassExceptions/CGI, and reference yet another
new page (containing your solution) from there. The name of that page
might be CGIQueryExtension or something. The examples that are
already there (e.g. under StandardClassExtensions/String) are a good
example.
Email me off-list if you need any help.
Cheers,
Gavin
···
On Tuesday, January 21, 2003, 8:54:37 AM, Travis wrote:
I was wondering where I could post such a modification so that others could
use it as well. It seems a bit silly to post a 10 line hack to the RAA.
Is there a page on the Wiki that would be appropriate?
On Monday 20 January 2003 04:54 pm, Travis Whitton wrote:
I hate to reply to my own post, but this is the solution I’ve come up with:
require ‘cgi’
class CGI
module QueryExtension
def
if @params[*args]
return @params[*args][0]
end
end
end
end
I was wondering where I could post such a modification so that others could
use it as well. It seems a bit silly to post a 10 line hack to the RAA.
Is there a page on the Wiki that would be appropriate?
You’re damn right there is. StandardClassExceptions is the place.
Create a page StandardClassExceptions/CGI, and reference yet another
new page (containing your solution) from there. The name of that page
might be CGIQueryExtension or something. The examples that are
already there (e.g. under StandardClassExtensions/String) are a good
example.
OK, I’ve added it to StandardClassExtensions/CGI. I’ll add a disclaimer to
indicate that this is the standard behaviour in Ruby 1.8.
I checked it out, and I like the way it makes it easy to test your web
applications; however, I don’t understand why it’s necessary to include
#!/usr/bin/narf at the top of your scripts when you’re coding in Ruby. Is
there a way to use this library in a standard fashion, and if not, why can’t
errors be reported directly to the browser without using the narf runner?
Also, how stable is narf? I’m about to embark on a serious project, and narf’s
RAA listing has it at beta status. With cgi.rb weighing in at under 2000 lines,
I have no worries of problems occuring I wouldn’t be able to fix. I’m not
knocking narf. It looks like it can do some very cool stuff. I’m just curious
if it would suite my particular needs.
I checked it out, and I like the way it makes it easy to test your web
applications; however, I don’t understand why it’s necessary to include
#!/usr/bin/narf at the top of your scripts when you’re coding in Ruby. Is
You actually don’t need to do this. The only function of this is to
dump errors to the Web browser in php/asp/jsp style. If you don’t use
it errors will go to the log in the traditional way.
there a way to use this library in a standard fashion, and if not, why can’t
errors be reported directly to the browser without using the narf runner?
They could, but you would need to add a top level exception handler in
your code. I think - if you have a better solution send me a patch :-).
Also, how stable is narf? I’m about to embark on a serious project, and narf’s
RAA listing has it at beta status. With cgi.rb weighing in at under 2000 lines,
I have no worries of problems occuring I wouldn’t be able to fix. I’m not
knocking narf. It looks like it can do some very cool stuff. I’m just curious
if it would suite my particular needs.
Narf is thoroughly unit tested (test first no-less), so is perhaps not
beta in the traditional sense. Areas likely to be a bit rough include mod_ruby
support (it may work, but isn’t used by any of the developers).
The documentation is also not very complete, but 'How do I…'s are
appreciated - they help focus attention on what’s missing.
If there are any issues (or if you have any questions), we usually get
them resolved fairly quickly - just post them to the mailing list: narf-lib-devel@lists.sourceforge.net
-Tom
···
On Wed, Jan 22, 2003 at 01:37:02AM +0900, Travis Whitton wrote:
You actually don’t need to do this. The only function of this is to
dump errors to the Web browser in php/asp/jsp style. If you don’t use
it errors will go to the log in the traditional way.
there a way to use this library in a standard fashion, and if not, why can’t
errors be reported directly to the browser without using the narf runner?
They could, but you would need to add a top level exception handler in
your code. I think - if you have a better solution send me a patch :-).
I currently just run everything under mod_ruby. If you set your RubyHandler
to Apache::RubyDebug.instance then errors are trapped and reported to the
browser. I tried running narf under mod_ruby and I get the following errors
/usr/local/lib/site_ruby/1.6/web.rb:770:in send_headers': undefined local variable or method mod_ruby_send_headers’
for #Web::CGI:0x44a1fc7c (NameError)
from /usr/local/lib/site_ruby/1.6/web.rb:552:in flush' from /usr/local/lib/site_ruby/1.6/web.rb:561:in close’
from /usr/local/lib/site_ruby/1.6/web.rb:143:in send' from /usr/local/lib/site_ruby/1.6/web.rb:143:in method_missing’
from /usr/local/lib/site_ruby/1.6/web.rb:869
from /usr/local/lib/site_ruby/1.6/web.rb:870
from ruby:0
I’m running mod_ruby 1.0.4, which is the latest version. I believe I have
narf installed correctly because it runs fine if I use the narf runner
and setup apache to handle *.rb files as cgi scripts. It just doesn’t seem
to like mod_ruby.