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" 
<[email protected]<mailto:[email protected]>> 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: 
[email protected]<mailto:[email protected]> 
[mailto:[email protected]] On Behalf Of Philippe Monnet
Sent: Sunday, August 30, 2009 1:05 PM
To: <mailto:[email protected]> 
[email protected]<mailto:[email protected]>
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 "#[email protected]}, Welcome to my IronCamping 
demo!"<mailto:#[email protected]%7d,WelcometomyIronCampingdemo%21>
  end
end










________________________________



_______________________________________________

Ironruby-core mailing list

<mailto:[email protected]>[email protected]<mailto:[email protected]>

<http://rubyforge.org/mailman/listinfo/ironruby-core>http://rubyforge.org/mailman/listinfo/ironruby-core



_______________________________________________
Ironruby-core mailing list
[email protected]<mailto:[email protected]>
http://rubyforge.org/mailman/listinfo/ironruby-core
_______________________________________________
Ironruby-core mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/ironruby-core

Reply via email to