44
44
before_models_committed = _signals .signal ('before-models-committed' )
45
45
46
46
47
- def _create_scoped_session (db , options ):
48
- if options is None :
49
- options = {}
50
- return orm .scoped_session (partial (_SignallingSession , db , ** options ))
51
-
52
-
53
47
def _make_table (db ):
54
48
def _make_table (* args , ** kwargs ):
55
49
if len (args ) > 1 and isinstance (args [1 ], db .Column ):
@@ -548,8 +542,7 @@ def __init__(self, app=None, use_native_unicode=True,
548
542
self .use_native_unicode = use_native_unicode
549
543
self .session_extensions = to_list (session_extensions , []) + \
550
544
[_SignallingSessionExtension ()]
551
-
552
- self .session = _create_scoped_session (self , session_options )
545
+ self .session = self .create_scoped_session (session_options )
553
546
554
547
self .Model = self .make_declarative_base ()
555
548
self .Model .query = _QueryProperty (self )
@@ -569,6 +562,12 @@ def metadata(self):
569
562
"""Returns the metadata"""
570
563
return self .Model .metadata
571
564
565
+ def create_scoped_session (self , options = None ):
566
+ """Helper factory method that creates a scoped session."""
567
+ if options is None :
568
+ options = {}
569
+ return orm .scoped_session (partial (_SignallingSession , self , ** options ))
570
+
572
571
def make_declarative_base (self ):
573
572
"""Creates the declarative base."""
574
573
return declarative_base (cls = Model , name = 'Model' ,
0 commit comments