Ignore:
Timestamp:
03/06/12 20:29:12 (8 years ago)
Author:
mnagni
Message:

Great improvement on how SA alchemy session is managed

File:
1 edited

Legend:

Unmodified
Added
Removed
  • mauRepo/MolesManager/trunk/src/MolesManager/molesSessionMiddleware.py

    r8323 r8325  
    44@author: mnagni 
    55''' 
    6 from MolesManager.moles3epb import Moles3EPB 
     6from MolesManager.moles3epb import Moles3EPBFactory 
    77from libs.migration.client import MigrationThread 
    88from MolesManager.settings import RUN_MIGRATION, MIGRATION_INTERVAL,\ 
     
    1010    MOLES3_DB_SCRIPT, EVENTS_DB, INFO_DB_CONNECTION 
    1111from libs.commons_db import DbManager 
    12 from libs.migration.MigrationEPB import MigrationEPB 
    1312from libs.migration.InfodbEPB import InfodbEPB 
    14 import logging 
     13from libs.migration.MigrationEPB import MigrationEPBFactory 
    1514 
    1615 
     
    2019    #This attribute should be not here. 
    2120    #unfortunately I cannot find any start/stop signals from Django 
    22     _migrationThread = MigrationThread(interval = MIGRATION_INTERVAL) 
     21    #_migrationThread = MigrationThread(interval = MIGRATION_INTERVAL) 
    2322    _epbInitialized = False 
    24      
    25     def _getNewMolesSession(self): 
    26         session = Moles3EPB.getNewMolesSession() 
    27         return session 
    28      
     23    _moles3EPBFactory = None 
     24    _migrationEPBFactory = None 
    2925     
    3026    def _doInitialization(self): 
     
    3329            
    3430        migrationDB = DbManager(MIGRATION_DB_CONNECTION, MIGRATION_DB_SCRIPT) 
    35         MigrationEPB.overrrideDBManager(migrationDB)        
     31        MolesSessionMiddleware._migrationEPBFactory = MigrationEPBFactory(migrationDB)                
    3632 
    3733        molesDB = DbManager(MOLES3_DB_CONNECTION, MOLES3_DB_SCRIPT, session_event_manager=EVENTS_DB) 
    38         Moles3EPB.overrrideDBManager(molesDB) 
     34        MolesSessionMiddleware._moles3EPBFactory = Moles3EPBFactory(molesDB) 
     35         
     36        MolesSessionMiddleware._migrationThread = MigrationThread( \ 
     37            MolesSessionMiddleware._moles3EPBFactory.createMoles3EPB(), \ 
     38            MolesSessionMiddleware._migrationEPBFactory.createMigrationEPB(), \ 
     39            interval = MIGRATION_INTERVAL ) 
    3940        MolesSessionMiddleware._epbInitialized = True       
    4041         
     
    7071            @deprecated: request.moles_session is going to be removed from all GUI-related instances 
    7172        ''' 
    72         #request.moles_session = self._getMolesSession() 
     73        request.moles3EPB = MolesSessionMiddleware._moles3EPBFactory.createMoles3EPB() 
    7374 
    7475 
    7576    def process_response(self, request, response): 
    76         """ 
    77         if hasattr(request, 'moles_session'): 
    78             request.moles_session.close() 
    79         """ 
     77        request.moles3EPB.close() 
    8078        return response 
    8179 
Note: See TracChangeset for help on using the changeset viewer.