- Timestamp:
- 11/06/12 10:27:19 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
mauRepo/MolesManager/trunk/src/MolesManager/molesSessionMiddleware.py
r8326 r8332 12 12 from libs.migration.InfodbEPB import InfodbEPBFactory 13 13 from libs.migration.MigrationEPB import MigrationEPBFactory 14 from sqlalchemy.exc import SQLAlchemyError 15 from django.core.context_processors import csrf 16 from django.shortcuts import render_to_response 14 17 15 18 … … 26 29 27 30 def _doInitialization(self): 31 28 32 infoDB = DbManager(INFO_DB_CONNECTION) 29 33 MolesSessionMiddleware._infodbEPBFactory = InfodbEPBFactory(infoDB) … … 41 45 interval = MIGRATION_INTERVAL ) 42 46 MolesSessionMiddleware._epbInitialized = True 43 47 44 48 self._migration() #see the note on MolesSessionMiddleware._migration 45 49 … … 67 71 68 72 def process_request(self, request): 69 if not MolesSessionMiddleware._epbInitialized:70 self._doInitialization()71 72 '''73 @deprecated: request.moles_session is going to be removed from all GUI-related instances74 '''75 request.moles3EPB = MolesSessionMiddleware._moles3EPBFactory.createMoles3EPB()76 73 try: 74 if not MolesSessionMiddleware._epbInitialized: 75 self._doInitialization() 76 77 request.moles3EPB = MolesSessionMiddleware._moles3EPBFactory.createMoles3EPB() 78 except SQLAlchemyError as ex: 79 MolesSessionMiddleware._epbInitialized = False 80 return self.process_exception(request, ex) 77 81 78 82 def process_response(self, request, response): 79 request.moles3EPB.close() 83 if hasattr(request, "moles3EPB"): 84 request.moles3EPB.close() 85 80 86 return response 81 87 82 83 88 def process_exception(self, request, exception): 84 pass85 """86 89 try: 87 session = request.moles_session 88 except AttributeError: 89 return 90 session.rollback() 91 session.close() 92 """ 90 c = {} 91 c['exception'] = exception 92 c.update(csrf(request)) 93 return render_to_response('errorTemplate.html', c) 94 except SQLAlchemyError as ex: 95 MolesSessionMiddleware._epbInitialized = False 96
Note: See TracChangeset
for help on using the changeset viewer.