Wee web-framework. It's great!

Michael:
Can I use Wee to access Oracle? I recently checked out Rails and was pretty
impressed. The ActiveRecord package has recently been patched to support
Oracle -- goods news. You recently mentioned that supporting ActiveRecord
wouldn't be terribly difficult, however, advocated trying out Og. Does Og
support Oracle? Thanks.

- Matt

···

-----Original Message-----
From: Michael Neumann [mailto:mneumann@ntecs.de]
Sent: Wednesday, February 16, 2005 11:27 PM
To: ruby-talk@ruby-lang.org
Cc: wee-talk@rubyforge.org
Subject: Re: Wee web-framework. It's great!

Joao Pedrosa wrote:

Hi,

I think it's important to say that the dynamic nature of Ruby
contributes to a nice development environment for Wee, that is,
whenever we are editing one of the components, and we save it, Wee
tries to reload it. If it had to be compiled it would slow this cycle
a little bit. And worse, because the compiler would complain at the
first sign of incorrectness, making errors appear when we surely new
that the component was not ready yet for compilation. Behind the
scenes, Wee remaps methods and creates components only when it's
necessary (time saving feature!)

It makes it appear that I'm editing an HTML and not a Ruby file.
That's it! Lovely.

Actually, it has less to do with editing an HTML and more with
creating the business logic of our application. The HTML is generated
automagically for us.

Look at this:

r.text_input.callback{|v| do_something_with v}.value(@original_value)

And for assigning it back to @original_value one can use this short-cut:

   r.text_input.callback{|@original_value|}.value(@original_value)

Yeah, this looks ugly :wink:

Or alternativly without the need to create a block:

   r.text_input.callback(:instance_variable_set, :original_value)

That's all that's needed to create the INPUT TYPE=TEXT object and at
the same time fill it with the default value and save its returning
value.

Add a submit button to it and you have your FORM.

r.submit_button.callback{save_edition}.value('Save Edition')

That's how everything is created, generally. There is more to it,
because it needs to support the simple and the complex, so it
"scales."

Just want to add, that this is only *one way* to generate HTML in Wee.
You can use other renderers simply by overwriting method #renderer_class
of your component class. Or you could use ERb-templates directly:

   # c.rb
   class MyComponent < Wee::Component
     template :render
   end

   # c.tpl
   <ul>
   <% (1..10).each do |i| %>
     <li><%= i %></li>
   <% end %>
   </ul>

You can even define "block"-templates (this of course is a bad example,
as templates do not accept parameters):

   # c.rb
   class MyComponent < Wee::Component
     template :render
     tempalte :render_item
   end

   # c.tpl
   <ul>
   <% (1..10).each do |@i| %>
     <% render_item %>
   <% end %>
   </ul>

   # c.tpl-item
   <li><%= @i %></li>

Or you can mix templates with programmatic html generation:

   # c.rb
   class MyComponent < Wee::Component
     template :render

     def render_item(i)
       r.li.with(i)
     end
   end

   # c.tpl
   <ul>
   <% (1..10).each do |i| %>
     <% render_item(i) %>
   <% end %>
   </ul>

Regards,

   Michael

Hmm writing an RDBMS adapter for Og is realtively easy. Perhaps someone
with
access to an Oracle database could do it. I worked on Oracle for a
recent project
and I may find some time to code the adapter myself. Then, again
another ruby
hacker could step in and help.

regards,
George.