コード例 #1
0
        def __call__(self, environ, start_response):
            app_iter = None
            reg = environ.setdefault('paste.registry', Registry())
            reg.prepare()
            if self.streaming:
                return self.streaming_iter(reg, environ, start_response)

            try:
                app_iter = self.application(environ, start_response)
            except Exception, e:
                # Regardless of if the content is an iterable, generator, list
                # or tuple, we clean-up right now. If its an iterable/generator
                # care should be used to ensure the generator has its own ref
                # to the actual object
                if environ.get('paste.evalexception'):
                    # EvalException is present in the WSGI stack
                    expected = False
                    for expect in environ.get('paste.expected_exceptions', []):
                        if isinstance(e, expect):
                            expected = True
                    if not expected:
                        # An unexpected exception: save state for EvalException
                        restorer.save_registry_state(environ)
                reg.cleanup()
                raise
コード例 #2
0
ファイル: registry.py プロジェクト: desarrollo1/tg2env
 def __call__(self, environ, start_response):
     app_iter = None
     reg = environ.setdefault('paste.registry', Registry())
     reg.prepare()
     if self.streaming:
         return self.streaming_iter(reg, environ, start_response)
     
     try:
         app_iter = self.application(environ, start_response)
     except Exception, e:
         # Regardless of if the content is an iterable, generator, list
         # or tuple, we clean-up right now. If its an iterable/generator
         # care should be used to ensure the generator has its own ref
         # to the actual object
         if environ.get('paste.evalexception'):
             # EvalException is present in the WSGI stack
             expected = False
             for expect in environ.get('paste.expected_exceptions', []):
                 if isinstance(e, expect):
                     expected = True
             if not expected:
                 # An unexpected exception: save state for EvalException
                 restorer.save_registry_state(environ)
         reg.cleanup()
         raise
コード例 #3
0
 def streaming_iter(self, reg, environ, start_response):
     try:
         for item in self.application(environ, start_response):
             yield item
     except Exception, e:
         # Regardless of if the content is an iterable, generator, list
         # or tuple, we clean-up right now. If its an iterable/generator
         # care should be used to ensure the generator has its own ref
         # to the actual object
         if environ.get('paste.evalexception'):
             # EvalException is present in the WSGI stack
             expected = False
             for expect in environ.get('paste.expected_exceptions', []):
                 if isinstance(e, expect):
                     expected = True
             if not expected:
                 # An unexpected exception: save state for EvalException
                 restorer.save_registry_state(environ)
         reg.cleanup()
         raise
コード例 #4
0
ファイル: registry.py プロジェクト: desarrollo1/tg2env
 def streaming_iter(self, reg, environ, start_response):
     try:
         for item in self.application(environ, start_response):
             yield item
     except Exception, e:
         # Regardless of if the content is an iterable, generator, list
         # or tuple, we clean-up right now. If its an iterable/generator
         # care should be used to ensure the generator has its own ref
         # to the actual object
         if environ.get('paste.evalexception'):
             # EvalException is present in the WSGI stack
             expected = False
             for expect in environ.get('paste.expected_exceptions', []):
                 if isinstance(e, expect):
                     expected = True
             if not expected:
                 # An unexpected exception: save state for EvalException
                 restorer.save_registry_state(environ)
         reg.cleanup()
         raise
コード例 #5
0
                # to the actual object
                if environ.get('paste.evalexception'):
                    # EvalException is present in the WSGI stack
                    expected = False
                    for expect in environ.get('paste.expected_exceptions', []):
                        if isinstance(e, expect):
                            expected = True
                    if not expected:
                        # An unexpected exception: save state for EvalException
                        restorer.save_registry_state(environ)
                reg.cleanup()
                raise
            except:
                # Save state for EvalException if it's present
                if environ.get('paste.evalexception'):
                    restorer.save_registry_state(environ)
                reg.cleanup()
                raise
            else:
                reg.cleanup()

            return app_iter

        def streaming_iter(self, reg, environ, start_response):
            try:
                for item in self.application(environ, start_response):
                    yield item
            except Exception, e:
                # Regardless of if the content is an iterable, generator, list
                # or tuple, we clean-up right now. If its an iterable/generator
                # care should be used to ensure the generator has its own ref
コード例 #6
0
ファイル: registry.py プロジェクト: desarrollo1/tg2env
         # to the actual object
         if environ.get('paste.evalexception'):
             # EvalException is present in the WSGI stack
             expected = False
             for expect in environ.get('paste.expected_exceptions', []):
                 if isinstance(e, expect):
                     expected = True
             if not expected:
                 # An unexpected exception: save state for EvalException
                 restorer.save_registry_state(environ)
         reg.cleanup()
         raise
     except:
         # Save state for EvalException if it's present
         if environ.get('paste.evalexception'):
             restorer.save_registry_state(environ)
         reg.cleanup()
         raise
     else:
         reg.cleanup()
     
     return app_iter
 
 def streaming_iter(self, reg, environ, start_response):
     try:
         for item in self.application(environ, start_response):
             yield item
     except Exception, e:
         # Regardless of if the content is an iterable, generator, list
         # or tuple, we clean-up right now. If its an iterable/generator
         # care should be used to ensure the generator has its own ref