<p dir="auto"><strong>Migrated issue, originally created by Elmer de Looff (<a href="https://github.com/edelooff">@edelooff</a>)</strong></p>
<p dir="auto">The <a href="http://docs.sqlalchemy.org/en/rel_0_9/core/event.html#named-argument-styles" rel="nofollow">events documentation</a> notes that since 0.9, the listens_for event decorator accepts a keyword <code class="notranslate">named</code>. With this, event arguments are provided as a dict. This works fine for the example of the Pool event, but fails for Engine events (for the current 0.9.7 release).</p>
<p dir="auto">A testcase to reproduce this and traceback are included as attachments. The relevant code is also included below:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="from sqlalchemy.event import listens_for
from sqlalchemy.engine import Engine

@listens_for(Engine, 'before_execute', named=True)
def intercept_execute(conn, **kw):
    print conn.engine.url"><pre class="notranslate"><code class="notranslate">from sqlalchemy.event import listens_for
from sqlalchemy.engine import Engine

@listens_for(Engine, 'before_execute', named=True)
def intercept_execute(conn, **kw):
    print conn.engine.url
</code></pre></div>
<hr>
<p dir="auto">Attachments: <a href="../wiki/imported_issue_attachments/3201/traceback.log">traceback.log</a> | <a href="../wiki/imported_issue_attachments/3201/engine_event_fail.py">engine_event_fail.py</a></p>
<p dir="auto"><strong>Migrated issue, originally created by Michael Bayer (<a href="https://github.com/zzzeek">@zzzeek</a>)</strong></p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="diff --git a/lib/sqlalchemy/orm/events.py b/lib/sqlalchemy/orm/events.py
index c50a7b0..bd0b48f 100644
--- a/lib/sqlalchemy/orm/events.py
+++ b/lib/sqlalchemy/orm/events.py
@@ -1490,7 +1490,7 @@ class AttributeEvents(event.Events):
     @classmethod
     def _listen(cls, event_key, active_history=False,
                 raw=False, retval=False,
-                propagate=False):
+                propagate=False, **kw):
 
         target, identifier, fn = \
             event_key.dispatch_target, event_key.identifier, event_key.fn
@@ -1509,14 +1509,14 @@ class AttributeEvents(event.Events):
                     return fn(target, value, *arg)
             event_key = event_key.with_wrapper(wrap)
 
-        event_key.base_listen(propagate=propagate)
+        event_key.base_listen(propagate=propagate, **kw)
 
         if propagate:
             manager = instrumentation.manager_of_class(target.class_)
 
             for mgr in manager.subclass_managers(True):
                 event_key.with_dispatch_target(
-                    mgr[target.key]).base_listen(propagate=True)
+                    mgr[target.key]).base_listen(propagate=True, **kw)
 
     def append(self, target, value, initiator):
         &quot;&quot;&quot;Receive a collection append event."><pre class="notranslate"><code class="notranslate">diff --git a/lib/sqlalchemy/orm/events.py b/lib/sqlalchemy/orm/events.py
index c50a7b0..bd0b48f 100644
--- a/lib/sqlalchemy/orm/events.py
+++ b/lib/sqlalchemy/orm/events.py
@@ -1490,7 +1490,7 @@ class AttributeEvents(event.Events):
     @classmethod
     def _listen(cls, event_key, active_history=False,
                 raw=False, retval=False,
-                propagate=False):
+                propagate=False, **kw):
 
         target, identifier, fn = \
             event_key.dispatch_target, event_key.identifier, event_key.fn
@@ -1509,14 +1509,14 @@ class AttributeEvents(event.Events):
                     return fn(target, value, *arg)
             event_key = event_key.with_wrapper(wrap)
 
-        event_key.base_listen(propagate=propagate)
+        event_key.base_listen(propagate=propagate, **kw)
 
         if propagate:
             manager = instrumentation.manager_of_class(target.class_)
 
             for mgr in manager.subclass_managers(True):
                 event_key.with_dispatch_target(
-                    mgr[target.key]).base_listen(propagate=True)
+                    mgr[target.key]).base_listen(propagate=True, **kw)
 
     def append(self, target, value, initiator):
         """Receive a collection append event.
</code></pre></div>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="from sqlalchemy import *
from sqlalchemy.orm import *
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy import event

Base = declarative_base()

class A(Base):
    __tablename__ = 'a'

    id = Column(Integer, primary_key=True)
    bs = relationship(&quot;B&quot;)


class B(Base):
    __tablename__ = 'b'

    id = Column(Integer, primary_key=True)
    a_id = Column(Integer, ForeignKey('a.id'))

e = create_engine(&quot;sqlite://&quot;, echo=True)

sess = Session(e)


@event.listens_for(A.bs, 'set', named=True)
def update_challenge_points(target, **kw):
    pass"><pre class="notranslate"><code class="notranslate">from sqlalchemy import *
from sqlalchemy.orm import *
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy import event

Base = declarative_base()

class A(Base):
    __tablename__ = 'a'

    id = Column(Integer, primary_key=True)
    bs = relationship("B")


class B(Base):
    __tablename__ = 'b'

    id = Column(Integer, primary_key=True)
    a_id = Column(Integer, ForeignKey('a.id'))

e = create_engine("sqlite://", echo=True)

sess = Session(e)


@event.listens_for(A.bs, 'set', named=True)
def update_challenge_points(target, **kw):
    pass
</code></pre></div>