Raise Security Error
from werkzeug.wrappers import BaseRequest from werkzeug.wsgi import responder from werkzeug.exceptions import HTTPException, NotFound flask raise 400 def view(request): raise NotFound() @responder def application(environ, start_response): request flask exceptions = BaseRequest(environ) try: return view(request) except HTTPException as e: return e As you can see http exception codes from this example those exceptions are callable WSGI applications. Because of Python 2.4 compatibility those do not extend from the response objects but only flask bad request exception from the python exception class. As a matter of fact they are not Werkzeug response objects. However you can get a response object by calling get_response() on a HTTP exception. Keep in mind that you have to pass an environment to get_response() because some errors fetch additional
information from the WSGI environment. If you want to hook in a different exception page to say, a 404 status code, you can add a second except for a specific subclass of an error: @responder def application(environ, start_response): request = BaseRequest(environ) try: return view(request) except NotFound, e: return not_found(request) except HTTPException, e: return e Error Classes¶ The following error classes exist in Werkzeug: exception werkzeug.exceptions.BadRequest(description=None, response=None)¶ 400 Bad Request Raise if the browser sends something to the application the application or server cannot handle. exception werkzeug.exceptions.Unauthorized(description=None, response=None)¶ 401 Unauthorized Raise if the user is not authorized. Also used if you want to use HTTP basic auth. exception werkzeug.exceptions.Forbidden(description=None, response=None)¶ 403 Forbidden Raise if the user doesn't have the permission for the requested resource but was authenticated. exception werkzeug.exceptions.NotFound(description=None, response=None)¶ 404 Not Found Raise if a resource does not exist and never existed. exception werkz
here for a quick overview of the site Help Center Detailed answers to any questions you might
Securityerror The Operation Is Insecure. Canvas
Sign in Pricing Blog Support Search GitHub This repository Watch 20 Star 65 Fork 30 bpsmith/tia Code Issues 7 Pull requests 0 Projects 0 https://github.com/bpsmith/tia/blob/master/tia/bbg/v3api.py Pulse Graphs Permalink Branch: master Switch branches/tags Branches Tags develop master Nothing http://www.ibm.com/support/docview.wss?crawler=1&uid=swg1PI17931 to show 0.3 0.2 0.1 Nothing to show Find file Copy path tia/tia/bbg/v3api.py 6a5fad7 Dec 2, 2015 bpsmith Fixed issue with table split and removed old comments 2 contributors Users who have contributed to this file bpsmith aspeight Raw Blame History 843 lines (723 sloc) 36.5 KB flask exceptions from collections import defaultdict, namedtuple from datetime import datetime import blpapi import pandas as pd import numpy as np import tia.util.log as log SecurityErrorAttrs = ['security', 'source', 'code', 'category', 'message', 'subcategory'] SecurityError = namedtuple('SecurityError', SecurityErrorAttrs) FieldErrorAttrs = ['security', 'field', 'source', 'code', 'category', 'message', 'subcategory'] FieldError = namedtuple('FieldError', FieldErrorAttrs) logger = log.get_logger(__name__) __all__ = ['Terminal'] class XmlHelper(object): @staticmethod def security_iter(nodearr): """ raise security error provide a security data iterator by returning a tuple of (Element, SecurityError) which are mutually exclusive """ assert nodearr.name() == 'securityData' and nodearr.isArray() for i in range(nodearr.numValues()): node = nodearr.getValue(i) err = XmlHelper.get_security_error(node) result = (None, err) if err else (node, None) yield result @staticmethod def node_iter(nodearr): assert nodearr.isArray() for i in range(nodearr.numValues()): yield nodearr.getValue(i) @staticmethod def message_iter(evt): """ provide a message iterator which checks for a response error prior to returning """ for msg in evt: if logger.isEnabledFor(log.logging.DEBUG): logger.debug(msg.toString()) if msg.asElement().hasElement('responseError'): raise Exception(msg.toString()) yield msg @staticmethod def get_sequence_value(node): """Convert an element with DataType Sequence to a DataFrame. Note this may be a naive implementation as I assume that bulk data is always a table """ assert node.datatype() == 15 data = defaultdict(list) cols =  for i in range(node.numValues()): row = node.getValue(i) if i == 0: # Get the ordered cols and assume they are constant cols = [str(row.getElement(_).name()) for _ in range(row.numElements())] for cidx in range(row.numElements()): col = row.getElement(cidx) data[str(col.name())].append(XmlHelper.as_value(col)) return pd.DataFrame(data, columns=cols) @staticmethod def as_value(ele): """ convert the specified element as a python value ""