ActiveRecord type validation

6 views
Skip to first unread message

Sean

unread,
Apr 20, 2008, 11:13:58 PM4/20/08
to SQLElixir
I sat down today and came up with a strategy for using ActiveRecord-
like validation in Elixr.

I put the code on my blog here: http://www.planningforaliens.com/?p=22

Does it look useful? Is it a bad idea? I'm open to any feedback/
criticism. It's working for me at the moment but I don't exactly have
a production app put together!

I took some direction from this guy and cleaned it up:
http://beachcoder.wordpress.com/2007/05/02/adding-event-callbacks-to-sqlalchemyelixir-classes/

- Sean

Gaetan de Menten

unread,
Apr 21, 2008, 7:04:17 AM4/21/08
to sqle...@googlegroups.com
On Mon, Apr 21, 2008 at 5:13 AM, Sean <sean.f...@gmail.com> wrote:
>
> I sat down today and came up with a strategy for using ActiveRecord-
> like validation in Elixr.
>
> I put the code on my blog here: http://www.planningforaliens.com/?p=22
>
> Does it look useful? Is it a bad idea? I'm open to any feedback/
> criticism. It's working for me at the moment but I don't exactly have
> a production app put together!

It looks useful, seems well done (at a quick glance) but... it's
already built-in in Elixir (in a very similar way than what you did).

from elixir.events import *

class MyClass(Entity):
@before_insert
def my_validation_function(self):
[do some stuff]

See:
http://elixir.ematia.de/trac/browser/elixir/trunk/tests/test_events.py
for more examples.

You probably missed it because of our lack of documentation. Sorry
about that. If you have some time, I'd be grateful if you could expand
our tutorial in the Wiki or start a new page introducing events, or
even add a docstring to the events module so that other users don't
need to reimplement the functionality themselves (even though the more
people become familiar with the codebase the better, it's sad when
it's for something already done).

Yes, he was actually the starting point for our own implementation as well.

--
Gaëtan de Menten
http://openhex.org

Sean

unread,
Apr 22, 2008, 12:57:34 AM4/22/08
to SQLElixir
It looks very similar to what I did but you use a decorator pattern
instead of Elixir Statements. Once I get this working in my app I will
gladly put something together for the wiki.

- Sean

On Apr 21, 4:04 am, "Gaetan de Menten" <gdemen...@gmail.com> wrote:
> On Mon, Apr 21, 2008 at 5:13 AM, Sean <sean.fiori...@gmail.com> wrote:
>
> > I sat down today and came up with a strategy for using ActiveRecord-
> > like validation in Elixr.
>
> > I put the code on my blog here: http://www.planningforaliens.com/?p=22
>
> > Does it look useful? Is it a bad idea? I'm open to any feedback/
> > criticism. It's working for me at the moment but I don't exactly have
> > a production app put together!
>
> It looks useful, seems well done (at a quick glance) but... it's
> already built-in in Elixir (in a very similar way than what you did).
>
> from elixir.events import *
>
> class MyClass(Entity):
> @before_insert
> def my_validation_function(self):
> [do some stuff]
>
> See:http://elixir.ematia.de/trac/browser/elixir/trunk/tests/test_events.py
> for more examples.
>
> You probably missed it because of our lack of documentation. Sorry
> about that. If you have some time, I'd be grateful if you could expand
> our tutorial in the Wiki or start a new page introducing events, or
> even add a docstring to the events module so that other users don't
> need to reimplement the functionality themselves (even though the more
> people become familiar with the codebase the better, it's sad when
> it's for something already done).
>
> > I took some direction from this guy and cleaned it up:
> > http://beachcoder.wordpress.com/2007/05/02/adding-event-callbacks-to-...
Reply all
Reply to author
Forward
0 new messages