[ANN] Nitro + Og 0.19.0: Og reloaded part2!

Hello everyone,

new versions of Nitro and Og were just released.

Downloads: http://rubyforge.org/projects/nitro
Mailing list: http://rubyforge.org/mailman/listinfo/nitro-general
Homepage: http://nitro.rubyforge.org

Og reloaded part 2: Another superb release introducing a balanced
mix of innovative new features, common but useful stuff and bug
fixes.

Some notable changes:

* Og polymorphic relations. A groundbreaking feature made possible by
Og's unique design and Ruby's power. Let's use an example to explain
the concept:

  class Comment
    ...
    belongs_to Object # polymorphic marker
  end

  class User
    ...
    has_many Comment
  end

  class Article
    ...
    has_many Comment
  end

  u = User.new
  u.comments << User::Comment('Hello')

  a = Article.new
  a.comments << Article::Comment('Wow!')

User::Comment and Article::Comment where automatically created by Og
and are serialized in different tables (also automatically created by
Og). This is the next step in DRY!

* Og now supports inheritance using the well known Single
Table Inheritance pattern. Thanks to Og's advanced design the pattern
is fully encapsulated:

  class Document
    ...
    schema_inheritance
  end

  class Article < Document
    ..
  end

  class Photo < Document
    ..
  end

  Document.all # => includes Articles and Photos
  Article.all # => only Articles

  User.documents # => Articles and Photos
  User.documents(:type => Photo) # => only photos.

Btw, this feature is orthogonal to the polymorphic relations feature
just described, giving the developer great flexibility.

* Added SUPERB support for auto reloading, the new system can detect
source changes everywhere! Based on original code by Michael Neumann.

* Introduced the concept of Flash, a temporal store where objects that
should be kept alive for the next request are saved.

* Recoded the Blog example to use the Elements system for shading
instead of XSLT. The new code runs easier under Windows (so the
no_xsl_blog example is now removed). Here comes an example:

  <Page>
    <Box>
      Please login as an author by entering the blog password.
      <br />
      The password is: <b>#{Blog.password}</b>.
    </Box>

    <Error>#@error</Error>
    ...
  </Page>

The <Page> tag is supported by the Page Ruby class to do the
programmatic rendering of templates or logic code:

  class Page
    def render
      ...
    end
  end

This system can be used to create a library of useful components to
abstract common tasks.

* The updated Blog example demonstrates how easy it is to
write webservices using Nitro and the experimental Service feature. The
code is so short, so lets paste it here:

  module BloggerApi
    SBlog = Struct.new(:url, :blogid, :blogName)

    def blogger__getUsersBlogs(appkey, username, password)
      Blog.all.collect { |b| SBlog.new('http://www.gmosx.com', b.oid,
b.title) }
    end
  end

  module MetaWeblogApi
    def metaWeblog__newPost(blogid, username, password, content, publish)
      entry = BlogEntry.new(content['title'], content['description'])
      entry.blog = Blog[blogid]
      entry.save
      entry.oid
    end
  end

  module MovableTypeApi
    SCategory = Struct.new(:categoryId, :categoryName)

    def mt__getCategoryList(blogid, username, password)
      blog = Blog[blogid]
      blog.categories.collect { |c| SCategory.new(c.oid, c.title) }
    end

    def mt__setPostCategories(postid, username, password, categories)
      cid = categories.first['categoryId']
      BlogEntry.update(postid, "category_oid=#{cid}")
      true
    end
  end

  class ApiController < Nitro::XmlRpcService
    include BloggerApi
    include MovableTypeApi
    include MetaWeblogApi
  end

  That's all!

* Integrated an SQLite3 patch by Ghislain Mary.

* Integrated PostgreSQL binary data patch by Michael Neumann.

* Fixed all reported bugs.

Nitro is an efficient, yet simple engine for developing professional
Web Applications using the Ruby language. Nitro aims to provide a
robust infrastructure for scalable web applications that can be
distributed over a server cluster. However, Nitro can also power simple
web applications for deployment on intranets or even personal
computers. Nitro integrates the powerful Og Object-Relational mapping
library.

Nitro is a multiparadigm application framework and will integrate ideas
from Rails, Wee, PHP, JSP and .NET

Nitro integrates the Og (ObjectGraph) object-relational mapping
library. Og provides transparent serialization of object graphs to an
RDBMS backend. Unlike other similar libraries Og maps standard Ruby
objects to SQL tables and not vice versa. Og provides a meta language
to describe the relations between objects, a flexible and intuitive API
for querying the database, raw access to the SQL language if needed
(for example to fine tune the automatically generated SQL tables, or
for custom queries), suports deserialization to Ruby objects or tuples,
automatically generates join tables for many_to_many relations and
provides a collection of usefull Mixins to synthesize common Entities.

Og is a combination of the best features of Active Record and the
former O-R mapping library included in Nitro (NDB). Adapters for
PostgreSQL, MySQL, SQLite and Oracle are included along with an
experimental In-Memory/Filesystem adapter.

I hope this software will be useful for you, and I would love to
receive your suggestions, ideas and bug reports.

have fun,
George Moschovitis

<snip>

Og is a combination of the best features of Active Record and the
former O-R mapping library included in Nitro (NDB). Adapters for
PostgreSQL, MySQL, SQLite and Oracle are included along with an
experimental In-Memory/Filesystem adapter.

have you played with using sqlite's in memory tables to leverage it's features
for this?

cheers.

-a

···

On Fri, 17 Jun 2005, George Moschovitis wrote:
--

email :: ara [dot] t [dot] howard [at] noaa [dot] gov
phone :: 303.497.6469
My religion is very simple. My religion is kindness.
--Tenzin Gyatso

===============================================================================

> experimental In-Memory/Filesystem adapter.
have you played with using sqlite's in memory tables to leverage it's features
for this?

Hello,

this is a pure ruby Og store implementation. A KirbyBase store will be
available soon as well (when I find time to finish it, or if someone
sends me a patch ;-))

I don't know anything about SQLite3's memory tables is this a different
table type like the Hash tables or InnoDB tables in Mysql? (btw 0.19.0
adds support for mysql table types).

regards,
George.

you just specify the table as being in memory and use them normally - only
they never hit disk. another, *nix specific, approach i use a lot is
(essentially)

   begin
     FileUtils::cp 'db', '/dev/shm/db'
     db = SQLite::Database::new '/dev/shm/db'
     yield db
   ensure
     FileUtils::mv '/dev/shm/db', 'db'
   end

which really helps out in some situations since the 'file' is really just in
memory so all intermediate writes and reads do not hit disk and only the
initial/final state requires disk activity. this means a power failure loses
everything after the first copy but this is often acceptable.

i also would add that, in practice, you should lock the db using posixlock
while moving in case an errant process is modifying the db during the copy...

cheers.

-a

···

On Sat, 18 Jun 2005, George Moschovitis wrote:

experimental In-Memory/Filesystem adapter.

have you played with using sqlite's in memory tables to leverage it's features
for this?

Hello,

this is a pure ruby Og store implementation. A KirbyBase store will be
available soon as well (when I find time to finish it, or if someone
sends me a patch ;-))

I don't know anything about SQLite3's memory tables is this a different
table type like the Hash tables or InnoDB tables in Mysql? (btw 0.19.0
adds support for mysql table types).

--

email :: ara [dot] t [dot] howard [at] noaa [dot] gov
phone :: 303.497.6469
My religion is very simple. My religion is kindness.
--Tenzin Gyatso

===============================================================================

Hmm, this is an interesting idea, and really trivial to add, so you
will see it in the next release.

regards,
George.