Python tornado.web.Finish() Examples
The following are 8
code examples of tornado.web.Finish().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
tornado.web
, or try the search function
.
Example #1
Source File: web_test.py From tornado-zh with MIT License | 5 votes |
def get(self): self.set_status(401) self.set_header('WWW-Authenticate', 'Basic realm="something"') if self.get_argument('finish_value', ''): raise Finish('authentication required') else: self.write('authentication required') raise Finish()
Example #2
Source File: web_test.py From tornado-zh with MIT License | 5 votes |
def get(self): self.set_status(401) self.set_header('WWW-Authenticate', 'Basic realm="something"') if self.get_argument('finish_value', ''): raise Finish('authentication required') else: self.write('authentication required') raise Finish()
Example #3
Source File: base_handler.py From Doodle with MIT License | 5 votes |
def cursor(self): cursor = self.get_argument('cursor', None) if cursor: try: cursor = int(cursor) except ValueError: self.redirect(self.request.path, permanent=True) raise Finish() if cursor < 0: raise HTTPError(404) else: cursor = None return cursor
Example #4
Source File: builder.py From binderhub with BSD 3-Clause "New" or "Revised" License | 5 votes |
def emit(self, data): """Emit an eventstream event""" if type(data) is not str: serialized_data = json.dumps(data) else: serialized_data = data try: self.write('data: {}\n\n'.format(serialized_data)) await self.flush() except StreamClosedError: app_log.warning("Stream closed while handling %s", self.request.uri) # raise Finish to halt the handler raise Finish()
Example #5
Source File: tornado.py From apm-agent-python with BSD 3-Clause "New" or "Revised" License | 5 votes |
def call(self, module, method, wrapped, instance, args, kwargs): if not hasattr(instance.application, "elasticapm_client"): # If tornado was instrumented but not as the main framework # (i.e. in Flower), we should skip it. return wrapped(*args, **kwargs) # Late import to avoid ImportErrors from tornado.web import Finish, HTTPError from elasticapm.contrib.tornado.utils import get_data_from_request e = args[0] if isinstance(e, Finish): # Not an error; Finish is an exception that ends a request without an error response return wrapped(*args, **kwargs) client = instance.application.elasticapm_client request = instance.request client.capture_exception( context={"request": get_data_from_request(instance, request, client.config, constants.ERROR)} ) if isinstance(e, HTTPError): elasticapm.set_transaction_result("HTTP {}xx".format(int(e.status_code / 100)), override=False) elasticapm.set_context({"status_code": e.status_code}, "response") else: elasticapm.set_transaction_result("HTTP 5xx", override=False) elasticapm.set_context({"status_code": 500}, "response") return wrapped(*args, **kwargs)
Example #6
Source File: tornado.py From skein with BSD 3-Clause "New" or "Revised" License | 5 votes |
def _raise_auth_required(self): from tornado import web self.set_status(401) self.write("Authentication required") self.set_header("WWW-Authenticate", "Negotiate") raise web.Finish()
Example #7
Source File: tornado.py From skein with BSD 3-Clause "New" or "Revised" License | 5 votes |
def _raise_auth_required(self): from tornado import web self.set_status(401) self.write("Authentication required") self.set_header("WWW-Authenticate", "PseudoAuth") raise web.Finish()
Example #8
Source File: web_test.py From EventGhost with GNU General Public License v2.0 | 5 votes |
def get(self): self.set_status(401) self.set_header('WWW-Authenticate', 'Basic realm="something"') if self.get_argument('finish_value', ''): raise Finish('authentication required') else: self.write('authentication required') raise Finish()