[Sqlalchemy-tickets] [sqlalchemy] #2775: bulk update/delete events / invent new system for changing
Brought to you by:
zzzeek
|
From: sqlalchemy <mi...@zz...> - 2013-07-07 16:24:15
|
#2775: bulk update/delete events / invent new system for changing event arguments
-------------------------+------------------------------------
Reporter: zzzeek | Owner: zzzeek
Type: enhancement | Status: new
Priority: medium | Milestone: 0.9.0
Component: orm | Severity: major - 1-3 hours
Keywords: | Progress State: in queue
-------------------------+------------------------------------
the bulk UD events should have access to the arguments that were passed:
{{{
#!python
def after_bulk_update(self, session, query, query_context, values,
synchronize_session, result):
""
}}}
and while we're at it, mapper events should get some more context too:
{{{
#!python
def before_insert(self, session, flush_context, mapper, connection,
target):
""
}}}
how can we pull this off? we'd need to build a really smart argument
adapter that uses inspect:
{{{
#!python
@event.legacy_signature("0.9", ["session", "query", "query_context",
"result"])
def after_bulk_update(self, session, query, query_context, values,
synchronize_session, result):
""
}}}
legacy_signature would need to receive the decorated fn, use inspect to
look at how many arguments it accepts, then produce a translation wrapper
corresponding to the given signature. it should even stick a
"..versionchanged::" directive into the docstring.
another issue, these events take a crapload of arguments. How do we deal
with that? Let's support this too:
{{{
#!python
@event.listens_for(Session, "after_bulk_update")
def after_update(self, **kw):
}}}
with the above signature the event system will detect that, and just send
all args in as key/value pairs, so that event handlers can be written more
simply just to look for what they need.
--
Ticket URL: <http://www.sqlalchemy.org/trac/ticket/2775>
sqlalchemy <http://www.sqlalchemy.org/>
The Database Toolkit for Python
|