@@ -467,11 +467,30 @@ def create_app():
467
467
class User(db.Model):
468
468
username = db.Column(db.String(80), unique=True)
469
469
pw_hash = db.Column(db.String(80))
470
+
471
+ You may also define your own SessionExtension instances as well when
472
+ defining your SQLAlchemy class instance. You may pass your custom instances
473
+ to the `session_extensions` keyword. This can be either a single
474
+ SessionExtension instance, or a list of SessionExtension instances. In the
475
+ following use case we use the VersionedListener from the SQLAlchemy
476
+ versioning examples.::
477
+
478
+ from history_meta import VersionedMeta, VersionedListener
479
+
480
+ app = Flask(__name__)
481
+ db = SQLAlchemy(app, session_extensions=[VersionedListener()])
482
+
483
+ class User(db.Model):
484
+ __metaclass__ = VersionedMeta
485
+ username = db.Column(db.String(80), unique=True)
486
+ pw_hash = db.Column(db.String(80))
470
487
"""
471
488
472
- def __init__ (self , app = None , use_native_unicode = True , session_extensions = None ):
489
+ def __init__ (self , app = None , use_native_unicode = True ,
490
+ session_extensions = None ):
473
491
self .use_native_unicode = use_native_unicode
474
- self .session_extensions = to_list (session_extensions , []) + [_SignallingSessionExtension ()]
492
+ self .session_extensions = to_list (session_extensions , []) + \
493
+ [_SignallingSessionExtension ()]
475
494
476
495
self .session = _create_scoped_session (self )
477
496
0 commit comments