On Feb 11, 2009, at 4:07 PM, Angri wrote:

>
> Michael, I see you dont like the ability to flush only specific
> objects as it brings more troubles than profit. I agree in almoust all
> cases, but... Let me show where does it need for me.
>
> It is not so rare case when developer needs to catch creating or
> updating instance. In some orm's (not hard to guess, which) it's done
> via simple model's method 'save()' or so (behavior of this methid is
> similar to `sess.flush([obj])`). One's able to explicitly call it
> wherever it needed. And it gives total control of what actually
> happen. Wait! I know that sqlalchemy's orm is much more high-level and
> it allows to abstract from low-level insert and update queries and
> rely on session's job. And I know that mapper supports extensions and
> it is able to listen insert and update events. But it is hard to use
> just because extension must be used in mapper's constructor arguments
> and it is (afaik) impossible to set extensions later.
>
> So, what it all about? I see that topic subject is subject of
> deprecate. And I will be forced to use mapper's extensions to have
> control on saving objects.

yeah, youre using it exactly for what you should not be using it for,  
to approximate the save() method on an active-record system.    
building your whole app around a fake save() paradigm is not at all  
how SQLA's unit of work was designed.  You can of course create your  
own CRUD system to issue inserts/updates yourself but then you dont  
get all the benefits of the UOW.   this makes me more sure of  
deprecating it.

> If so, what do you think about some kind of async events system?
> Something like PyDispatcher, Louie or Django's dispatch. It can be
> used not only with mapper's events but also with ddl-events. The main
> pro of this approach is the ability to subscribe to (or unsubscribe
> from) such events in run-time.

the ORM and the schema system are two totally different systems.   
MapperExtension and SessionExtension handle ORM events.  the DDL()  
object handles DDL events.  The MapperExtension/SessionExtension can  
easily be used to create an on-events system based on object  
signature, like __on_save__(), etc.  Extensions can also be set at any  
time by saying mapper.extension.append(yourext), similar for Session.




--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" 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/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to