|
14 | 14 | import time
|
15 | 15 | import sqlalchemy
|
16 | 16 | from math import ceil
|
17 |
| -from types import MethodType |
18 | 17 | from functools import partial
|
19 | 18 | from flask import _request_ctx_stack, abort
|
20 | 19 | from flask.signals import Namespace
|
@@ -466,31 +465,31 @@ def create_app():
|
466 | 465 | class User(db.Model):
|
467 | 466 | username = db.Column(db.String(80), unique=True)
|
468 | 467 | pw_hash = db.Column(db.String(80))
|
469 |
| - |
| 468 | +
|
470 | 469 | You may also define your own SessionExtension instances as well when
|
471 | 470 | defining your SQLAlchemy class instance. You may pass your custom instances
|
472 |
| - to the `session_extensions` keyword. This can be either a single |
| 471 | + to the `session_extensions` keyword. This can be either a single |
473 | 472 | SessionExtension instance, or a list of SessionExtension instances. In the
|
474 |
| - following use case we use the VersionedListener from the SQLAlchemy |
| 473 | + following use case we use the VersionedListener from the SQLAlchemy |
475 | 474 | versioning examples.::
|
476 |
| - |
| 475 | +
|
477 | 476 | from history_meta import VersionedMeta, VersionedListener
|
478 |
| - |
| 477 | +
|
479 | 478 | app = Flask(__name__)
|
480 | 479 | db = SQLAlchemy(app, session_extensions=[VersionedListener()])
|
481 |
| - |
| 480 | +
|
482 | 481 | class User(db.Model):
|
483 | 482 | __metaclass__ = VersionedMeta
|
484 | 483 | username = db.Column(db.String(80), unique=True)
|
485 | 484 | pw_hash = db.Column(db.String(80))
|
486 | 485 | """
|
487 | 486 |
|
488 |
| - def __init__(self, app=None, use_native_unicode=True, |
| 487 | + def __init__(self, app=None, use_native_unicode=True, |
489 | 488 | session_extensions=None):
|
490 | 489 | self.use_native_unicode = use_native_unicode
|
491 | 490 | self.session_extensions = to_list(session_extensions, []) + \
|
492 | 491 | [_SignallingSessionExtension()]
|
493 |
| - |
| 492 | + |
494 | 493 | self.session = _create_scoped_session(self)
|
495 | 494 |
|
496 | 495 | self.Model = declarative_base(cls=Model, name='Model')
|
|
0 commit comments