Re: Strange behavior with RubyAuthenHandler on ruby 1.8.1 + modruby 1.0.7
LHERBIER Lois <[email protected]>
| Newsgroups | gmane.comp.apache.mod-ruby |
|---|---|
| Message-ID | <[email protected]> |
Shugo Maeda wrote: >Hello, > >At Thu, 01 Apr 2004 18:54:16 +0200, >LHERBIER Lois <[email protected]> wrote: > > >>We have an intranet developped with ruby 1.6.7 + modruby 1.0.3 + apache >>1.3.x and we want to use ruby 1.8.1 + modruby 1.0.7 + apache 1.3.x. >>But we have a problem with RubyAuthenHandler on this new plateform. I >>have spent a long time identifying this "bug". >> >> >(snip) > > >>Can you please help me to find the problem ? >> >> > >In ruby-1.8, the behaviour of include in scripts loaded by >load(filename, true) seems to be changed from ruby-1.6. > >For example, the followint test works on ruby-1.6, but doesn't >work in ruby-1.8. > >--- b.rb --- >module A > module B > end >end >----------- >--- test.rb --- >p A::B >include A >p B >-------------- > >excelsior:/tmp$ ruby1.6 -v -r b -e 'load("./test.rb", true)' >ruby 1.6.8 (2003-07-09) [i386-linux] >A::B >A::B >excelsior:/tmp$ ruby1.8 -v -r b -e 'load("./test.rb", true)' >ruby 1.8.1 (2004-02-03) [i386-linux] >A::B >./test.rb:2: warning: main#include in the wrapped load is effective only for toplevel >./test.rb:3: uninitialized constant #<Module:0x402e8f48>::B (NameError) > from -e:1:in `load' > from -e:1 > > Thanks for the patch :o) I have noticed this change in ruby 1.8 on the 1.8 changelog and I see the warning ( warning: main#include in the ...) on my apache log too when it crashes. But I don't use "load", but "require", "load (xx,true)" evaluates the file in an anonymous module, "require" doesn't (?). I don't understand why this problem appears only when I "require" the foo.rb from the file containing Apache ruby auth handler (auth.rb). If I don't require 'foo.rb' form the Apache ruby auth handler (auth.rb), everything works fine (test.rbx) ! Is the "require" done by RubyAuthenHandler when parsing the file is different from the "require" done by test.rbx ? Is a "require 'xx' " done in a file containing the Apache Ruby Auth handler converted in "load('xx',true)" by RubyAuthenHandler ? I have added the the files in tgz in my first email but it doesn't seem to work on this ML. The files and all the information for this problem are detailled below. Thanks for all your help. Loïs --------------------------------------------------------- The files : ********** ./libs/bar/foo.rb ./libs/bar/auth.rb ./test.rbx ./libs/bar/foo.rb--------------------------- module Bar class Foo def Foo.name "Foo!" end # Foo.name end # class Foo end # module Bar ____________________________ ./libs/bar/auth.rb--------------------------- require 'bar/foo' # if I comment this line there is no problem to load test.rbx module Bar module Site def Site.authenticate(r) return(Apache::OK) end # def Site.authenticate() end # module Site end # module Bar ____________________________ this page print "Foo!" when it works :oP ./test.rbx---------------------------------- require 'bar/foo' include Bar cgi=CGI.new puts cgi.header puts Foo.name ____________________________ httpd.conf --------------------- RubyAddPath '/home/test/bug/libs' alias /test "/home/test/bug/" <Location "/test"> Options +ExecCGI +Indexes AuthType Basic AuthName "Auth" require valid-user RubyRequire 'bar/auth' RubyAuthenHandler Bar::Site </Location> ____________________________ The Error : ************ /home/test/bug/test.rbx:5: uninitialized constant #<Module:0x448b093c>::Foo /usr/lib/ruby/1.8/apache/ruby-debug.rb:73:in `load' /usr/lib/ruby/1.8/apache/ruby-debug.rb:73:in `handler'