[Nitro] Help understanding ... process

George Moschovitis george.moschovitis at gmail.com
Wed Aug 3 02:55:10 EDT 2005

Hello Marcus,

For more details on this check out the file lib/nitro/compiler.rb
Process goes more or less like this:

You get a request uri in the following general format:


First the Dispatcher uses the the controller part to select the
appropriate controller. This controller  acts as the Render from now

The the action part of the uri is extracted. The Render tries to call
the method "#{action}_action"
If the method does not exists the Compiler kicks in an tries to
generate the method.

The body of this method is built dynamically. If a method called
"#{action}" exists in the Controller it is called. Then if a template
called "#{action}.xhtml" exists in the Controllers template_root, it
is converted to a method called "#{action}_template" and then called
by "#{action}_action" after the call to "#{action}".

A lot of other things happen in the generated method, have a look at
the code for more details.

Hope this helps :)


On 8/2/05, Marcus Edwards <redentis at gmail.com> wrote:
> Hi All,
> I've been working through the Nitro tutorial at NitroHQ and have a
> question based on section
> "Chapter 7: Shaping Up" http://www.nitrohq.com/view/NSBS_Shaping_Things_Up.
> The tutorial states:
> "...The form action is set to "post_entry," so you'll need to add some
> server code to respond to that request ... First, Nitro will look for
> post_entry.html. If not found, then post_entry.xhtml is the target. If
> that does not exist, Nitro will attempt to invoke post_entry on the
> default component..."
> This is all perfectly logical and it what I would expect. However, the
> text then goes on to say:
> "...Finally, add a new template (named post_entry.xhtml to map to the
> method) to render the new entry..."
> My question then is this: if the dispatch sequence for requests looks
> for .xhtml templates *ahead* of the controllers (first quote),
> wouldn't adding the .xhtml template "to render the results of the
> request" (second quote) short-circuit the process and prevent the
> dispatcher from using the controller?
> It would help me enormously if someone could describe the whole
> decision chain from when a request is received until the response is
> returned. E.g.
> 1. Server: request received
> 2. Server: apply request filters...
> 3. Dispatcher: find controller
>     3.1 .html? ...
>          3.1.1 html controller (SimpleController)
>          ...
>     3.2 .xhtml
>          3.2.1 xhtml controller (SimpleController? Compiler?)
>          ...
>     3.3 Server.map[request url fragment #1]?
>           3.3.1 Controller: has method matching request url fragment #2?
>  etc.
> Obviously a UML sequence diagram would be superb but a description at
> the very least would help. I'm more then happy to sketch up the
> diagram if someone can explain how it works. I'll try walking through
> the code to get at the answer to this but if someone has a ready
> explanation, I'm all ears.
> Thanks,
> Marcus
> _______________________________________________
> Nitro-general mailing list
> Nitro-general at rubyforge.org
> http://rubyforge.org/mailman/listinfo/nitro-general


More information about the Nitro-general mailing list