Rails and Madeleine

P

Phil Tomson

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
 
S

Samuel Kvarnbrink

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 :)

//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: (e-mail address removed)
(e-mail address removed)
(e-mail address removed)


"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
 
D

David Heinemeier Hansson

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 :)

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).
 
F

Florian Frank

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.
 
V

vruz

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. :)

or a Madeleine that serialises to SQLite instead of the fs.
See: http://www.sqlite.org/lockingv3.html

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

Jim Weirich

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.

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!
 
A

Aredridel

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. :)

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.
 
D

Dema

Samuel said:
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 :)

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
 
A

Anders Bengtsson

David said:
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

--
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,169
Messages
2,570,920
Members
47,464
Latest member
Bobbylenly

Latest Threads

Top