3

The class MapperExtension has some methods, and before_insert, before_update, ... all have a parameter connection.

def before_insert(self, mapper, connection, instance):

I've read the documents of MapperExtension, but found nothing about this connection. What is it? And how to use it?

Freewind
  • 193,756
  • 157
  • 432
  • 708

1 Answers1

2

It's an instance of Connection class. Recent versions of SQLAlchemy distribution have examples directory, see examples/nested_sets/nested_sets.py to get an idea on how to use it in mapper extension.

zmo
  • 24,463
  • 4
  • 54
  • 90
Denis Otkidach
  • 32,032
  • 8
  • 79
  • 100