On Sep 26, 2012, at 12:36 PM, Ladislav Lenart wrote:

> Hello.
> 
>> I can guarantee you all SQL goes through the same channels.
> 
> No doubts there :-)
> 
> 
>> perhaps you registered the event with a specific Engine or Connection that is
> not the one involved in the test.
> 
> This might be it, but I don't know what should I supply instead. I have the
> following setUp:
> 
> class DbTestCase(object):
>    def setUp(self):
>        self.Base = create_base()
>        self._create_db()
>        self.connection = self.engine.connect()
>        self.trans = self.connection.begin()
>        self.session = Session(bind=self.connection, autoflush=False)
>        self._sql_emitters = set()
>        event.listen(
>            self.engine,
>            "before_cursor_execute",
>            self._before_cursor_execute
>        )
> 
> I have tried every object (and its type) present in the setUp method, but all
> fail with
> 
>    InvalidRequestError: No such event 'before_cursor_execute' for target...

you've got self.connection already.   so you want to listen on that:

event.listen(self.connection, ...)

when a Connection is constructed, it takes a snapshot of the event listeners 
associated with its parent Engine.    This is for performance reasons so that 
event dispatch doesn't need to check two separate dispatch collections.

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.

Reply via email to