param() method weirdness in cgi.rb 
Author Message
 param() method weirdness in cgi.rb

Hello --

Here's something bizarre involving cgi.rb (at least, I have no idea
whatsoever why it's happening).

All I want to do is grab a hidden value.  I'm using the param()
method, which looks like this:

    def param(name)

    end

However, it does nothing.  It doesn't even seem to be getting called.
If I change it to:

    def param(name)
      "BLAH!"
    end

I still don't get a value.

HOWEVER......

If I change the name of the method to "get_param", or "blah", or
anything other than "param", it works.

Here's my script:

   require 'cgi'


   def first




         end
       end
     end
   end

   def second


         "second time"
       end
     end
   end


   when "hi" then second
   else first
   end

If I change the two called to param to get_param (and change it in
cgi.rb), then the flip from "first" to "second" works.  Otherwise it
doesn't.

This is so weird that I feel a certain serenity about it....  Insights
and explanations welcome.

David

--
David Alan Black


Web:   http://www.*-*-*.com/ ~blackdav



Wed, 21 Apr 2004 21:40:39 GMT  
 param() method weirdness in cgi.rb
Hello --

I think I figured it out.

Later in cgi.rb, during some automatic method creation, another method
called param is created dynamically.  And it's actually
"PARAM".downcase, hence my grepping wasn't sufficient :-)

I think param()-the-first had best be renamed....

David

--
David Alan Black


Web:  http://pirate.shu.edu/~blackdav



Wed, 21 Apr 2004 21:44:56 GMT  
 param() method weirdness in cgi.rb

Quote:

> Later in cgi.rb, during some automatic method creation, another method
> called param is created dynamically.  And it's actually
> "PARAM".downcase, hence my grepping wasn't sufficient :-)

in short: CGI (can) downcase(s) params?

Tobi

--
Tobias Reif
http://www.pinkjuice.com/myDigitalProfile.xhtml

go_to('www.ruby-lang.org').get(ruby).play.create.have_fun
http://www.pinkjuice.com/ruby/



Wed, 21 Apr 2004 22:10:36 GMT  
 param() method weirdness in cgi.rb

Quote:


> > Later in cgi.rb, during some automatic method creation, another method
> > called param is created dynamically.  And it's actually
> > "PARAM".downcase, hence my grepping wasn't sufficient :-)

> in short: CGI (can) downcase(s) params?

It's the method name itself that gets downcased.  Have a look around
line 1815 of cgi.rb -- there's a whole bunch of dynamic method
creation.

David

--
David Alan Black


Web:  http://pirate.shu.edu/~blackdav



Wed, 21 Apr 2004 22:40:13 GMT  
 param() method weirdness in cgi.rb

Quote:

> It's the method name itself that gets downcased.  Have a look around
> line 1815 of cgi.rb -- there's a whole bunch of dynamic method
> creation.

Ah I see; interesting.

P.S. "element.downcase" describes part of what's new in the current
version of HTML: all element and attr names are lowercase.

--
Tobias Reif
http://www.pinkjuice.com/myDigitalProfile.xhtml

go_to('www.ruby-lang.org').get(ruby).play.create.have_fun
http://www.pinkjuice.com/ruby/



Wed, 21 Apr 2004 22:43:56 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. cgi.param(x) gone in 1.6.8?

2. CGI in RB (for MAC OS X)

3. RB as a cgi?

4. cgi/session.rb help: How does it work ?

5. fcgi and cgi-lib.rb

6. Strange cgi.rb <--> StringIO problem

7. eruby and cgi.rb

8. cgi.rb - sending same named headers

9. cgi.rb:490:in `+': failed to convert Fixnum into String

10. are there unit tests for cgi.rb?

11. cgi.rb multipart question

12. Multithreading and cgi.rb

 

 
Powered by phpBB® Forum Software