Back to my mental disconnect thing:

Let's not overlook that by having a responds_to_events statement, you
are defining a second class of statements--events--and extending their
definition to "statements that are activated by the responds_to_events
statement". This is ok, so long as the concept of an event is as
extensible as the concept of a statement itself, or so long that you
specifically define the set of events.

What I mean is, can I define new events for my class, and have those
events fit into the framework of statements that are activated by
using responds_to_events, or is the set of six (?) events a hardcoded
set of statements that are explicitly listed and defined as the
events?

If the events are hardcoded into responds_to_events, maybe it would be
better to have a statement for each event.

~jon

On Jul 30, 8:03 pm, Jonathan LaCour <[EMAIL PROTECTED]>
wrote:
> Okay, I just committed the first preliminary version of the event
> handling hooks for Elixir as an extension.  Here is a quick sample:
>
>      from elixir import *
>      from elixir.ext.events import *
>
>      class Person(Entity):
>          has_field('name', Unicode)
>          responds_to_events()
>
>          @before_insert
>          def test(self):
>              print '-' * 80
>              print self.name
>              print '-' * 80
>
> Again, the only reason that the "responds_to_events" statement is needed
> is to insert the proper mapper extension into the entity, since the
> class, table, mapper, etc. don't exist at the time that the method is
> decorated.
>
> I don't personally mind the requirement, however we could avoid it by
> simply having the events module add its mapper extension into the global
> mapper extensions on import, like so:
>
>      from sqlalchemy.orm.mapper import global_extensions
>      global_extensions.append(event_mapper_extension)
>
> Would you like me to make this change, or keep it as it is?  The
> downside to such an approach is that this mapper extension would be
> added onto every single mapper in the process, even if just one Entity
> is using events. It should be minor overhead, but its still something to
> consider.
>
> I am open to other suggestions on how to solve this :)
>
> --
> Jonathan LaCourhttp://cleverdevil.org


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