Jimmy Schementi
2009-Aug-31 05:47 UTC
[Ironruby-core] Trying to run _why''s Camping framework on IronRack / IIS
Ah, gotcha. Thanks for the explanation Tomas. I''ll make that change.
~Jimmy
Sent from my phone
On Aug 30, 2009, at 10:24 PM, "Tomas Matousek" <Tomas.Matousek at
microsoft.com<mailto:Tomas.Matousek at microsoft.com>> wrote:
The constant is not set when hosting IR and using Engine.Execute() or
ScriptScope.Execute().
It is only set by ScriptSource.ExecuteProgram(). The reason is that each call to
the former methods creates a new top-level binding and therefore we don?t know
which one should be the one that is stored in TOPLEVEL_BINDING. The latter is
meant to be used to execute the main top-level code (i.e. the ?program?) and it
sets the TOPLEVEL_BINDING up. It also handles SystemExit exception so that
?exit? works according to Ruby?s semantics.
IronRack should probably use ExecuteProgram to execute the main request
processing script.
Tomas
From: ironruby-core-bounces at rubyforge.org<mailto:ironruby-core-bounces at
rubyforge.org> [mailto:ironruby-core-bounces at rubyforge.org] On Behalf Of
Philippe Monnet
Sent: Sunday, August 30, 2009 1:05 PM
To: <mailto:ironruby-core at rubyforge.org> ironruby-core at
rubyforge.org<mailto:ironruby-core at rubyforge.org>
Subject: Re: [Ironruby-core] Trying to run _why''s Camping framework on
IronRack / IIS
Today I dug deeper in the issue by breaking down the goes method of Camping in
small chunks and evaluating them both in IR and MRI. I found that one thing
expected by Camping was the global constant TOPLEVEL_BINDING.
Apparently the constant was not defined in IR. A Google search found it in:
ironruby/Merlin/Main/Languages/Ruby/Libs/hacks.rb
And when I explicitly required it, the constant appeared and Camping worked
immediately on IronRack.
Could someone explain what the constant is for and why it is located in
hacks.rb?
Is it ok to I be using hacks.rb?
Philippe
PS - I am pretty excited to run Camping now! I just had to make a couple changes
on top of IronRack to make it work.
Philippe Monnet wrote:
I have been leveraging IronRack to try to get a sample Camping application up
and running.
I seem to be able to require the camping library fine but then as try to hit the
famous "Camping.goes :Demo" line, IronRuby return an error stating
that the constant #<Class:Camping> is not initialized.
So I tried to do the same test using the IR command line executable, but ran
into the same issue (note that the same test works fine in IRB). What is strange
is that the camping framework is loaded and if I query the constants in the
Camping module I get back what I would expect. Is this a module loading issue?
How can I troubleshoot this further?
Here is the IR''s transcript:
---------------
>ir
IronRuby 0.9.0.0 on .NET 2.0.50727.3082
Copyright (c) Microsoft Corporation. All rights reserved.
>>> require ''rubygems''
=> true
>>> gem ''rack''
=> true
>>> require ''rack''
=> true
>>> gem ''camping''
=> true
>>> require ''camping''
=> ["Camping"]
>>> require ''demo''
C:/Ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.3/lib/active_support/dependencies.rb:105:in
`const_missing'': uninitialized constant
#<Class:Camping>::TOPLEVEL_BINDING (NameError)
from
C:/Ruby/lib/ruby/gems/1.8/gems/camping-1.5.180/lib/camping.rb:39:in
`goes''
from ./demo.rb:3
from :0
from :0:in `require''
from custom_require.rb:30:in `require''
from dependencies.rb:156:in `require''
from dependencies.rb:490:in `new_constants_in''
from dependencies.rb:154:in `require''
---------------
And the basic ''demo.rb'' looks like the following:
require ''camping''
Camping.goes :Demo
module Demo
def Demo.create
end
end
module Demo::Models
end
module Demo::Controllers
class Index < R ''/''
def get
render :index
end
end
end
module Demo::Views
def layout
html do
body do
self << yield
end
end
end
def index
h1 "#{@input.name}, Welcome to my IronCamping
demo!"<mailto:#%7B at input.name%7D,WelcometomyIronCampingdemo%21>
end
end
________________________________
_______________________________________________
Ironruby-core mailing list
<mailto:Ironruby-core at rubyforge.org>Ironruby-core at
rubyforge.org<mailto:Ironruby-core at rubyforge.org>
<http://rubyforge.org/mailman/listinfo/ironruby-core>http://rubyforge.org/mailman/listinfo/ironruby-core
_______________________________________________
Ironruby-core mailing list
Ironruby-core at rubyforge.org<mailto:Ironruby-core at rubyforge.org>
http://rubyforge.org/mailman/listinfo/ironruby-core
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://rubyforge.org/pipermail/ironruby-core/attachments/20090831/4191a673/attachment.html>
Tomas Matousek
2009-Sep-01 03:27 UTC
[Ironruby-core] Trying to run _why''s Camping framework on IronRack / IIS
Cool! Great repro. This issue is related to bug http://ironruby.codeplex.com/WorkItem/View.aspx?WorkItemId=1535 (Range is Enumerable and therefore implements Enumerable#to_a, which should be called by * operator). I?ve amended it and increased its priority to High. The workaround is to call to_ary/to_a explicitly:>>> r = ''a''..''d''=> "a".."d">>> [*(r.respond_to?(:to_ary) ? r.to_ary : r.to_a)].size=> 4 Tomas From: ironruby-core-bounces at rubyforge.org [mailto:ironruby-core-bounces at rubyforge.org] On Behalf Of Philippe Monnet Sent: Monday, August 31, 2009 7:50 PM To: ironruby-core at rubyforge.org Subject: Re: [Ironruby-core] Trying to run _why''s Camping framework on IronRack / IIS Now that I can run a minimalistic Camping app, I am moving on to get the Camping Blog app example to work. As I am now testing additional features like Camping session and access to ActiveRecord on SQL Server, I am starting a list of issues I have encountered. These issues seem triggered by differences between the two Ruby implementations. For example, the following code is used in the generation of a Camping session id: - in MRI: irb(main):001:0> [*''a''..''d''] => ["a", "b", "c", "d"] irb(main):002:0> [*''a''..''d''].size => 4 - in IR: >>> [*''a''..''d''] => ["a".."d"] >>> [*''a''..''d''].size => 1 As of tonight I can now establish a session and get the cookies and session state to work right. But forms Once I am done, I will write-up the other findings and work-arounds. Philippe Jimmy Schementi wrote: Ah, gotcha. Thanks for the explanation Tomas. I''ll make that change. ~Jimmy Sent from my phone On Aug 30, 2009, at 10:24 PM, "Tomas Matousek" <Tomas.Matousek at microsoft.com<mailto:Tomas.Matousek at microsoft.com>> wrote: The constant is not set when hosting IR and using Engine.Execute() or ScriptScope.Execute(). It is only set by ScriptSource.ExecuteProgram(). The reason is that each call to the former methods creates a new top-level binding and therefore we don?t know which one should be the one that is stored in TOPLEVEL_BINDING. The latter is meant to be used to execute the main top-level code (i.e. the ?program?) and it sets the TOPLEVEL_BINDING up. It also handles SystemExit exception so that ?exit? works according to Ruby?s semantics. IronRack should probably use ExecuteProgram to execute the main request processing script. Tomas From: ironruby-core-bounces at rubyforge.org<mailto:ironruby-core-bounces at rubyforge.org> [mailto:ironruby-core-bounces at rubyforge.org] On Behalf Of Philippe Monnet Sent: Sunday, August 30, 2009 1:05 PM To: ironruby-core at rubyforge.org<mailto:ironruby-core at rubyforge.org> Subject: Re: [Ironruby-core] Trying to run _why''s Camping framework on IronRack / IIS Today I dug deeper in the issue by breaking down the goes method of Camping in small chunks and evaluating them both in IR and MRI. I found that one thing expected by Camping was the global constant TOPLEVEL_BINDING. Apparently the constant was not defined in IR. A Google search found it in: ironruby/Merlin/Main/Languages/Ruby/Libs/hacks.rb And when I explicitly required it, the constant appeared and Camping worked immediately on IronRack. Could someone explain what the constant is for and why it is located in hacks.rb? Is it ok to I be using hacks.rb? Philippe PS - I am pretty excited to run Camping now! I just had to make a couple changes on top of IronRack to make it work. Philippe Monnet wrote: I have been leveraging IronRack to try to get a sample Camping application up and running. I seem to be able to require the camping library fine but then as try to hit the famous "Camping.goes :Demo" line, IronRuby return an error stating that the constant #<Class:Camping> is not initialized. So I tried to do the same test using the IR command line executable, but ran into the same issue (note that the same test works fine in IRB). What is strange is that the camping framework is loaded and if I query the constants in the Camping module I get back what I would expect. Is this a module loading issue? How can I troubleshoot this further? Here is the IR''s transcript: --------------- >ir IronRuby 0.9.0.0 on .NET 2.0.50727.3082 Copyright (c) Microsoft Corporation. All rights reserved. >>> require ''rubygems'' => true >>> gem ''rack'' => true >>> require ''rack'' => true >>> gem ''camping'' => true >>> require ''camping'' => ["Camping"] >>> require ''demo'' C:/Ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.3/lib/active_support/dependencies.rb:105:in `const_missing'': uninitialized constant #<Class:Camping>::TOPLEVEL_BINDING (NameError) from C:/Ruby/lib/ruby/gems/1.8/gems/camping-1.5.180/lib/camping.rb:39:in `goes'' from ./demo.rb:3 from :0 from :0:in `require'' from custom_require.rb:30:in `require'' from dependencies.rb:156:in `require'' from dependencies.rb:490:in `new_constants_in'' from dependencies.rb:154:in `require'' --------------- And the basic ''demo.rb'' looks like the following: require ''camping'' Camping.goes :Demo module Demo def Demo.create end end module Demo::Models end module Demo::Controllers class Index < R ''/'' def get render :index end end end module Demo::Views def layout html do body do self << yield end end end def index h1 "#{@input.name}, Welcome to my IronCamping demo!"<mailto:#%7B at input.name%7D,WelcometomyIronCampingdemo%21> end end ________________________________ _______________________________________________ Ironruby-core mailing list Ironruby-core at rubyforge.org<mailto:Ironruby-core at rubyforge.org> http://rubyforge.org/mailman/listinfo/ironruby-core _______________________________________________ Ironruby-core mailing list Ironruby-core at rubyforge.org<mailto:Ironruby-core at rubyforge.org> http://rubyforge.org/mailman/listinfo/ironruby-core ________________________________ _______________________________________________ Ironruby-core mailing list Ironruby-core at rubyforge.org<mailto:Ironruby-core at rubyforge.org> http://rubyforge.org/mailman/listinfo/ironruby-core -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/ironruby-core/attachments/20090901/3ca382b8/attachment.html>