[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Rails and Madeleine

ptkwt

4/9/2005 7:03:00 AM


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
8 Answers

Samuel Kvarnbrink

4/9/2005 10:14:00 AM

0

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://sa...

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



David Heinemeier Hansson

4/9/2005 1:16:00 PM

0

> 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).
--
David Heinemeier Hansson,
http://www.basec... -- Web-based Project Management
http://www.rubyon... -- Web-application framework for Ruby
http://www.loudthi... -- Broadcasting Brain



Florian Frank

4/9/2005 2:30:00 PM

0

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.

--
Florian Frank


vruz

4/9/2005 3:20:00 PM

0

>
> 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/lock...

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


Jim Weirich

4/9/2005 3:48:00 PM

0

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.

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!

--
-- Jim Weirich jim@weirichhouse.org http://onest...
-----------------------------------------------------------------
"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)


Aredridel

4/9/2005 3:58:00 PM

0

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


Dema

4/10/2005 3:05:00 PM

0

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

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

Anders Bengtsson

4/11/2005 9:32:00 AM

0

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

--