Giter Site home page Giter Site logo

flask-exceptional's People

Contributors

imlucas avatar jab avatar jzempel avatar lost-theory avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

flask-exceptional's Issues

expose Exceptional object in app.extensions

Would be nice to be able to access the Exceptional object via app.extensions. The flask-babel extension for instance does this:

ipdb> pp app.extensions
{'babel': <flaskext.babel.Babel object at 0x102a51b10>,
 'exceptional': {'name': 'flask-exceptional',
                 'protocol_version': 5,
                 'version': 'unknown'}}

Is this a standard practice, or is there some other place it's kicking around?

Exceptional.publish seems broken?

I'm trying to integrate flask-exceptional into our rq job queue. This seemed straightforward since you have provided Exceptional.publish but I've ran into a few issues. I'm not sure if this is user error or an actual regression. It appears that the flask-extension code is still expecting the request context when it shouldn't.

Here is my error handler code for rq:

def report_to_exceptional_handler(job, exc_type, exc_value, traceback):                                                                                    
    tb = Traceback(exc_type, exc_value, traceback)                                                                                                                                                                                                                                                                   
    Exceptional.publish(gotham.app.config, tb)  

I then get the following exception.

[2013-02-07 21:16] DEBUG: horse: Invoking exception handler <function report_to_exceptional_handler at 0xb7e52a8>
Traceback (most recent call last):
  File "worker.py", line 31, in <module>
    w.work()
  File "/home/bryan/.virtualenvs/gotham/local/lib/python2.7/site-packages/rq/worker.py", line 326, in work
    self.fork_and_perform_job(job)
  File "/home/bryan/.virtualenvs/gotham/local/lib/python2.7/site-packages/rq/worker.py", line 342, in fork_and_perform_job
    self.main_work_horse(job)
  File "/home/bryan/.virtualenvs/gotham/local/lib/python2.7/site-packages/rq/worker.py", line 377, in main_work_horse
    success = self.perform_job(job)
  File "/home/bryan/.virtualenvs/gotham/local/lib/python2.7/site-packages/rq/worker.py", line 402, in perform_job
    self.handle_exception(job, *sys.exc_info())
  File "/home/bryan/.virtualenvs/gotham/local/lib/python2.7/site-packages/rq/worker.py", line 443, in handle_exception
    fallthrough = handler(job, *exc_info)
  File "worker.py", line 16, in report_to_exceptional_handler
    Exceptional.publish(gotham.app.config, tb)
  File "/home/bryan/.virtualenvs/gotham/local/lib/python2.7/site-packages/flask_exceptional.py", line 144, in publish
    exceptional._post_data(traceback=traceback)
  File "/home/bryan/.virtualenvs/gotham/local/lib/python2.7/site-packages/flask_exceptional.py", line 232, in _post_data
    app = context.app if context else stack.top.app
AttributeError: 'NoneType' object has no attribute 'app'

It appears that this code is trying to pull out the variable stack.app.top where stack is really a flask._request_ctx_stack. However when I'm in my job queue we do not have a request context which is exactly what I thought the publish function was built to handle. Am I just using this incorrectly or should I submit a patch?

Thanks.

-bryan

TypeError: <cStringIO...> is not JSON serializable

Flask-exceptional is throwing the following error whenever it tries to post an exception:

Traceback (most recent call last):
  File "/base/python27_runtime/python27_lib/versions/1/google/appengine/runtime/wsgi.py", line 174, in Handle
    result = handler(self._environ, self._StartResponse)
  File "packages/flask/app.py", line 1518, in __call__
    return self.wsgi_app(environ, start_response)
  File "packages/flask/app.py", line 1506, in wsgi_app
    response = self.make_response(self.handle_exception(e))
  File "packages/flaskext/exceptional.py", line 142, in ret_val
    self._post_data(context)
  File "packages/flaskext/exceptional.py", line 184, in _post_data
    "exception": self.__get_exception_data(traceback)
  File "/base/python27_runtime/python27_dist/lib/python2.7/json/__init__.py", line 231, in dumps
    return _default_encoder.encode(obj)
  File "/base/python27_runtime/python27_dist/lib/python2.7/json/encoder.py", line 201, in encode
    chunks = self.iterencode(o, _one_shot=True)
  File "/base/python27_runtime/python27_dist/lib/python2.7/json/encoder.py", line 264, in iterencode
    return _iterencode(o, 0)
  File "/base/python27_runtime/python27_dist/lib/python2.7/json/encoder.py", line 178, in default
    raise TypeError(repr(o) + " is not JSON serializable")
TypeError: <cStringIO.StringI object at 0x2981158> is not JSON serializable

I am using the new python27 App Engine runtime.

AttributeError: 'functools.partial' object has no attribute '__module__'

I am trying to use Flask-Exceptional on Mac OSX version 10.9.3 on python 2.7.5 .
On calling Exceptional(app) an error is encountered.
Here's the traceback.

Traceback (most recent call last):
  File "__init__.py", line 1, in <module>
    from app import app, login_manager, redis_client, api
  File "/Users/tushar/dev/frankly/api/app.py", line 14, in <module>
    exceptional = Exceptional(app)
  File "/Library/Python/2.7/site-packages/flask_exceptional.py", line 53, in __init__
    self.init_app(app)
  File "/Library/Python/2.7/site-packages/flask_exceptional.py", line 100, in init_app
    app.handle_exception = self._get_exception_handler(app)
  File "/Library/Python/2.7/site-packages/flask_exceptional.py", line 198, in _get_exception_handler
    @wraps(handle_exception)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/functools.py", line 33, in update_wrapper
    setattr(wrapper, attr, getattr(wrapped, attr))
AttributeError: 'functools.partial' object has no attribute '__module__'

Here's what i found on stackoverflow.
Error encountered using decorator to update wrapper

Please Look into the problem.
Thanks.

SimpleCookie code fails in python 2.6.4

Flask-Exceptional dies when setting cookie values in 2.6.4:

Traceback (most recent call last):
  File "/var/home/steven-kryskalla/project/lib/python2.6/site-packages/Flask-0.7dev_20110406-py2.6.egg/flask/app.py", line 1014, in __call__
    return self.wsgi_app(environ, start_response)
  File "/var/home/steven-kryskalla/project/lib/python2.6/site-packages/Flask-0.7dev_20110406-py2.6.egg/flask/app.py", line 1002, in wsgi_app
    response = self.make_response(self.handle_exception(e))
  File "/var/home/steven-kryskalla/project/lib/python2.6/site-packages/flaskext/exceptional.py", line 144, in ret_val
    self._post_data(context)
  File "/var/home/steven-kryskalla/project/lib/python2.6/site-packages/flaskext/exceptional.py", line 180, in _post_data
    "request": self.__get_request_data(context.app, context.request, context.session),
  File "/var/home/steven-kryskalla/project/lib/python2.6/site-packages/flaskext/exceptional.py", line 294, in __get_request_data
    headers["Cookie"] = cookie.output(header='', sep=';').strip()
  File "/var/home/steven-kryskalla/Python-2.6.4/Lib/Cookie.py", line 594, in output
    result.append( V.output(attrs, header) )
AttributeError: 'unicode' object has no attribute 'output'

This happens because Cookie.py in the 2.6.4 stdlib has a bug that is fixed in later versions:

http://bugs.python.org/issue5275
http://hg.python.org/cpython/rev/c51721d64451/

Maybe that cookie[k] = v code can be used as a workaround for older versions of python.

Invalid JSON Encoder with Flask 0.10

Current version uses flask.json.econder.encode_basestring, but 'encoder' no longer exists in the flask.json module, could potentially use flask.json._json.encoder, but that feels a little hacky.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.