The problem with using decorators here is that it doesn't compare to
things like has_field/with_fields/belongs_to/etc. before_insert is a
DSL statement at the same level of the other Elixir statements, and
represents the ability to implement whatever data-defining behavior
you want  as statements.

Callbacks like "before_insert_test" can be decorated, but not field
definitions, like you see in has_field.

I'm not saying that there shouldn't be decorators in the style of
@before_insert. Such a syntax would be very simple to implement, after
all. But to have it be the preferred syntax for defining event
callbacks would form a mental disconnect between the event hook
statements and other statements.

~jon

On Jul 30, 6:24 am, Vsevolod Balashov <[EMAIL PROTECTED]>
wrote:
> Hello!
>
> beachcoder wrote:
> > Hi, I posted the code from Pylons pastebin to
> >http://sqlelixir.googlegroups.com/web/callbacks.py. Please go ahead if
> > you want to add any of it to the Elixir codebase.
>
> please change this ugly implementation
>
>     class Car(Entity):
>         has_field('name', String(30))
>
>         before_insert('before_insert_test')
>         def before_insert_test(self): print "%s before insert"
> %self.name
>
> to decorator-like
>
>     class Car(Entity):
>         has_field('name', String(30))
>
>         @before_insert
>         def before_insert_test(self): print "%s before insert"
> %self.name


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"SQLElixir" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlelixir?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to