Rails and Madeleine

The latest announcement about Instiki being on Rails now got me to
wondering....

Instiki uses Madeleine as it's database (object persistence). So I'm
thinking that this means that Rails (specifically ActiveRecords) has
built-in support for using Madeleine (correct assumption?), meaning that
madeleine can be specified as the adapter in the database.yml file? But
if you do that how do you set up your tables since I don't think madeleine
accepts SQL.
(NOTE: I am a total newbie to SQL, databases, etc. so I may be using
incorrect terminology and/or assumptions here)

Phil

Well, to be accurate it is a Rails app without Active Record. Due to the way it's designed, AR won't work with non-SQL databases (and that will probably never change). However, it would be possible to create something that mimics AR through duck typing. But methods like find_by_sql would be a bit tricky, of course :slight_smile:

//samuel

···

The latest announcement about Instiki being on Rails now got me to
wondering....

Instiki uses Madeleine as it's database (object persistence). So I'm
thinking that this means that Rails (specifically ActiveRecords) has
built-in support for using Madeleine (correct assumption?), meaning that
madeleine can be specified as the adapter in the database.yml file? But
if you do that how do you set up your tables since I don't think madeleine
accepts SQL.
(NOTE: I am a total newbie to SQL, databases, etc. so I may be using
incorrect terminology and/or assumptions here)

Phil

________________________
Samuel Kvarnbrink

blog: http://samuelk.info

mail: samuel@acc.umu.se
       samuel.kvarnbrink@minervaskolan.se
       samuel.kvarnbrink@humlab.umu.se

"On two occasions I have been asked [by members of Parliament!],
Pray, Mr. Babbage, if you put into the machine wrong figures,
will the right answers come out?' I am not able rightly to
apprehend the kind of confusion of ideas that could provoke such
a question."
-- Charles Babbage

Well, to be accurate it is a Rails app without Active Record. Due to the way it's designed, AR won't work with non-SQL databases (and that will probably never change). However, it would be possible to create something that mimics AR through duck typing. But methods like find_by_sql would be a bit tricky, of course :slight_smile:

Right. Most of Active Record is designed the way it is because of the inherent mismatch between objects and relational data. Madeleine has no such mismatch, so there's no mapping to be made in the sense of ORM. Hence, it doesn't make that much sense to attempt huddling Madeleine in under AR semantics.

Would would make sense, though, is possibly to abstract things like the validation framework from Active Record and put it into Active Support. That would allow a Madeleine- or ActiveLDAP-backed model to use the same validations framework.

I have had an intent to make Madeleine work even more transparently with Rails for a long time, though. I don't know when I'll have the time to work on it. But basically, I think there's a bunch of stuff around managing the Madeleine server instance and calling command-generating methods that could be made substantially easier.

Instiki started some of this work. Perhaps someone will take it upon themselves to carry on with this. Creating a "version" of Rails that defaults to the Madeleine way and make Madeleine super easy to use as a model alternative.

Just don't try to shoehorn it in under Active Record semantics. That would nullify the benefit of Madeleine (no mapping needed) and leave it with only the disadvantages (entire data set in memory, data access only through OO system).

···

--
David Heinemeier Hansson,
http://www.basecamphq.com/ -- Web-based Project Management
http://www.rubyonrails.org/ -- Web-application framework for Ruby
http://www.loudthinking.com/ -- Broadcasting Brain

Samuel Kvarnbrink wrote:

Well, to be accurate it is a Rails app without Active Record. Due to
the way it's designed, AR won't work with non-SQL databases (and that

will probably never change). However, it would be possible to create
something that mimics AR through duck typing. But methods like
find_by_sql would be a bit tricky, of course :slight_smile:

Yes, I successfully ported AR and kept the same API to work with a RDF
database called Sesame (that doesn't work with SQL) in an academic
project. Pratically all original AR methods are there with no
modification to their signatures, although their performance and
implementation may vary a LOT.

By keeping the duck typing of the ported Base library I was able to
include almost all supporting libraries with no modifications at all,
including associations, validations, acts, aggregations, callbacks and
others.

It's doable and duck typing is a big friend.

rgds

David Heinemeier Hansson wrote:

I have had an intent to make Madeleine work even more transparently with Rails for a long time, though. I don't know when I'll have the time to work on it. But basically, I think there's a bunch of stuff around managing the Madeleine server instance and calling command-generating methods that could be made substantially easier.

The biggest problem with Madeleine in the context of web applications is concurrency. It cannot be used it in multi-process mode.

I wonder if it would be technically feasible to have some sort of a backend/frontend separation, where a Madeleine backend would be a separate process, and a Madeleine-enabled frontend would connect to it if it's already there, or start it automatically and then connect if it's not.

Hmm... sounds like a Madeleine feature wish. :slight_smile:

···

--
Best regards,

Alexey Verkhovsky

Ruby Forum: http://ruby-forum.org (moderator)
RForum: http://rforum.andreas-s.net (co-author)
Instiki: http://instiki.org (maintainer)

This describes the dictionary drb server example, that comes with
Madeleine, pretty good.

···

On 2005-04-09 23:22:03 +0900, Alexey Verkhovsky wrote:

I wonder if it would be technically feasible to have some sort of a
backend/frontend separation, where a Madeleine backend would be a
separate process, and a Madeleine-enabled frontend would connect to it
if it's already there, or start it automatically and then connect if
it's not.

--
Florian Frank

Yes! I was just thinking this week how useful it would be to be able to do
the validation independent of ActiveRecord.

Go for it!

···

On Saturday 09 April 2005 09:15 am, David Heinemeier Hansson wrote:

Would would make sense, though, is possibly to abstract things like the
validation framework from Active Record and put it into Active Support.
That would allow a Madeleine- or ActiveLDAP-backed model to use the
same validations framework.

--
-- Jim Weirich jim@weirichhouse.org http://onestepback.org
-----------------------------------------------------------------
"Beware of bugs in the above code; I have only proved it correct,
not tried it." -- Donald Knuth (in a memo to Peter van Emde Boas)

David Heinemeier Hansson wrote:

Would would make sense, though, is possibly to abstract things like the
validation framework from Active Record and put it into Active Support.
That would allow a Madeleine- or ActiveLDAP-backed model to use the
same validations framework.

If only I could win the lottery so I could spend my days adapting Rails
to Madeleine and vice versa...

As someone mentioned, there is a simple attempt at running Madeleine
through DRb distributed with Madeleine. I haven't tried it in anything
near production-like circumstances and there probably are pitfalls, but
basically a DRb service seems like a good solution. (Even though an
application's architecture would have to be designed with the slower
distributed method calls in mind).

/Anders

···

--

Florian Frank wrote:

···

On 2005-04-09 23:22:03 +0900, Alexey Verkhovsky wrote:

I wonder if it would be technically feasible to have some sort of a
backend/frontend separation, where a Madeleine backend would be a
separate process, and a Madeleine-enabled frontend would connect to it
if it's already there, or start it automatically and then connect if it's not.
   

This describes the dictionary drb server example, that comes with
Madeleine, pretty good.

Thanks for pointing it out, I'll look there.
Does anybody have such a thing in production?

--
Best regards,

Alexey Verkhovsky

Ruby Forum: http://ruby-forum.org (moderator)
RForum: http://rforum.andreas-s.net (co-author)
Instiki: http://instiki.org (maintainer)

The biggest problem with Madeleine in the context of web applications is
concurrency. It cannot be used it in multi-process mode.

I wonder if it would be technically feasible to have some sort of a
backend/frontend separation, where a Madeleine backend would be a
separate process, and a Madeleine-enabled frontend would connect to it
if it's already there, or start it automatically and then connect if
it's not.

Hmm... sounds like a Madeleine feature wish. :slight_smile:

or a Madeleine that serialises to SQLite instead of the fs.
See: File Locking And Concurrency In SQLite Version 3

that could help Madeleine -> any SQL-based ORM translation.

I wonder if it would be technically feasible to have some sort of a
backend/frontend separation, where a Madeleine backend would be a
separate process, and a Madeleine-enabled frontend would connect to it
if it's already there, or start it automatically and then connect if
it's not.

Hmm... sounds like a Madeleine feature wish. :slight_smile:

I was thinking that a madeleine run that way could be a lot simpler,
since the backend-separation means you don't have to have the complex
code to figure out whether the object is inside madeleine or outside.

dRb + auto-spawn-if-connection-refused would be perfect.