One of the points that Rails ActiveRecord got right IMHO is the fact
that models should validate themselves. So I started to work on adding
rail-like validation to Elixir entities, using formencode. Here's a
first Q&D and incomplete attempt, I'm awaiting for criticism,
suggestions and other feedback.
http://sqlelixir.googlegroups.com/web/entities.py
NB : one of the main differences with ActiveRecords is that this
modules automagically adds validators based on the entity's fields.
At first glance, it looks GREAT. I'll have a more thorough look
tomorrow and I'll try to think how and if we should include that
directly in Elixir.
--
Gaëtan de Menten
http://openhex.org
Wow!
I was considering adding statements exactly like these to Elixir, but it
looks like you have done all the work for us :)
I'll take a closer look as soon as I can. Some examples that illustrate
how to use your statements would be very helpful.
--
Jonathan LaCour
http://cleverdevil.org
One of the points that Rails ActiveRecord got right IMHO is the fact
that models should validate themselves. So I started to work on adding
rail-like validation to Elixir entities, using formencode. Here's a
first Q&D and incomplete attempt, I'm awaiting for criticism,
suggestions and other feedback.
Nope. Forms do of course have to handle their own conversion/
validation, but this is a different issue.
Looks like my previous answer got lost somewhere in the ether, so...
On 25 avr, 23:02, Jonathan LaCour <jonathan-li...@cleverdevil.org>
wrote:
>
> Wow!
>
> I was considering adding statements exactly like these to Elixir, but it
> looks like you have done all the work for us :)
Not quite *all* the work yet !-)
There's still a lot to do like pre/post validation hooks, more
validate_XXX statements, etc, etc, and of course test, test, test.
> I'll take a closer look as soon as I can. Some examples that illustrate
> how to use your statements would be very helpful.
Yes, indeed. Anyway, I won't go much further without first adding real
unit-tests, so there should be working examples pretty soon now.
Gaetan : if adding a dependency on formencode is not a problem for you
(I mean you three guys), I'd of course be happy (and honored) to see
this code becoming part of Elixir - when it'll be a bit less dirty
and a bit more tested.
Thanks you two for these first feedbacks. I'm awaiting your
observations and suggestions after a closer look.
Bruno
> Gaetan : if adding a dependency on formencode is not a problem for you
> (I mean you three guys), I'd of course be happy (and honored) to see
> this code becoming part of Elixir - when it'll be a bit less dirty
> and a bit more tested.
Sorry for the delay. I still haven't had the opportunity to look more
closely at your code and probably won't have for some time (sorry
about that... you know... life and all that stuff).
But anyway, after giving it some thoughts, I don't thing this belongs
in. Don't get me wrong, I'm pretty sure your code is very useful (and
I'll probably use it on a later project) but if we include your code
that would be a important change of the scope of the library.
For now, it has been: "a declarative layer on top of SQLAlchemy", and
that's it nothing more.
I'm open for discussion about this, but my personal stance at the
moment is to try to keep the scope of Elixir as it is (ie quite
narrow) but fill it as well as we can rather than going in all sorts
of directions and ending up with a semi-complete-framework.
> Sorry for the delay. I still haven't had the opportunity to look more
> closely at your code and probably won't have for some time (sorry
> about that... you know... life and all that stuff).
Its the same response from me! I have a lot going on right now between
life and work, so I haven't had much time to spend on Elixir in a while
:/ But, I am excited by the initial code that I have seen in your
validation statements, but haven't gone over it enough to really provide
feedback.
> I'm open for discussion about this, but my personal stance at the
> moment is to try to keep the scope of Elixir as it is (ie quite
> narrow) but fill it as well as we can rather than going in all sorts
> of directions and ending up with a semi-complete-framework.
I would be open to providing an additional egg and including details
about it on the Elixir page. Ideally, I would like a lot of people
to start creating their own DSL statements for doing various things,
including validation, tagging, etc. If we get enough of these rolling,
I'd like to have something on the Elixir website that lists these
"plugins" and provides a place to hold their documentation. I'd even be
in favor of placing these plugins into our subversion repository, each
in their own separate projects.
To me, this is a great way to build up Elixir. The core provides just
what Gaetan said: a declarative layer on top of SQLAlchemy, along with a
basis for extending it with plugins.
Don't worry you both and don't feel sorry - I have a life too, and had
almost no time to work on this since my OP.
(snip)
> > I'm open for discussion about this, but my personal stance at the
> > moment is to try to keep the scope of Elixir as it is (ie quite
> > narrow) but fill it as well as we can rather than going in all sorts
> > of directions and ending up with a semi-complete-framework.
>
> I would be open to providing an additional egg and including details
> about it on the Elixir page. Ideally, I would like a lot of people
> to start creating their own DSL statements for doing various things,
> including validation, tagging, etc. If we get enough of these rolling,
> I'd like to have something on the Elixir website that lists these
> "plugins" and provides a place to hold their documentation. I'd even be
> in favor of placing these plugins into our subversion repository, each
> in their own separate projects.
>
> To me, this is a great way to build up Elixir. The core provides just
> what Gaetan said: a declarative layer on top of SQLAlchemy, along with a
> basis for extending it with plugins.
All this seems quite sensible. But then it would be useful (IMHO) to
have some (more or less) standardized way to organize/package/deploy
these plugins...
My 2 cents...
And of course someone already wrote part of this:
http://pylonshq.com/pasties/244
http://beachcoder.wordpress.com/2007/05/02/adding-event-callbacks-to-sqlalchemyelixir-classes/
> And of course someone already wrote part of this:
> http://pylonshq.com/pasties/244
Very cool!
These statements seem like they would make wonderful additions to
elixir, and we'd just need to contact the author of the statements about
adding them in. I would be happy to write some tests and documentation
updates for the new statements.
What does everyone (Gaetan, Daniel, etc.) think?
Well, I had already seen that code (notice the reference to it in the
TODO file ;-)) and I'm fully in favor of providing an easy way to
extend the mapper, but, as I said in the TODO file:
"Beachcoder's code seem pretty cool but I wonder if it wouldn't
be possible to do something simpler." (ie less repetitive).
Btw: I've got quite a few changes in Elixir in my pipeline... Stay tuned...