trustyou / retwist Goto Github PK
View Code? Open in Web Editor NEWWrite JSON REST APIs in the Twisted framework
License: MIT License
Write JSON REST APIs in the Twisted framework
License: MIT License
The Sentry error capturing system currently integrated in retwist will more or less only tell you that an error happened, but not how. Most importantly, it will not tell you the request URL or POST data, which would be crucial to effectively debug an error.
Given the Twisted request
object, you can prepare the data like this to match Sentry's interface:
context = {"request": {
'url': str(request.URLPath()),
'method': request.method,
'headers': list(request.requestHeaders.getAllRawHeaders()),
'query_string': request.uri.replace(request.path, '').strip('?'),
'data': {k: v[0] for k, v in request.args.items()}
}}
Given an instance client
of raven.Client, this context
object can then either be stored for future errors via client.context.merge(context)
or be passed directly to the client.captureException
method as attribute data
.
(For TY employees, this is WIDGET-2298 in JIRA)
This project uses ensureDeferred
, which was added in Twisted 16.4. This minimum requirement should be documented in setup.py.
The sentry integration currently doesn't capture a traceback object, which would be very nice to have for debugging.
Raising an error with non-ASCII characters in the error message raises a server-side exception:
# e.g. in json_GET
raise Error(400, u"Not a valid argument: äöü".encode("utf-8"))
Either make this work, or document (and enforce?) that only ASCII is allowed in error messages.
Add support to python3.7
Depending on pytest-dev/pytest-twisted#30 to be accomplished.
Make it possible to report server errors to Sentry, optionally.
Do this from log_server_error
, by subclassing it enabling it via flag or something. Inject the configuration there somehow.
Don't add Sentry as a dependency - retwist should install without it.
Add an example that demonstrates usage.
retwist has type annotations which could help validate types in projects that use it.
However, in order to make that possible, we need to signal that we have valid type annotations, e.g. by placing a py.typed
marker file.
Reporting maximum allowed parameter value reports "Minimum value" instead of "Maximum value"
Reproduce by calling a JsonResource
with a non-ASCII value for retwist.Param
, e.g. /resource?param=ümläüt
Works on Python 3, but fails on 2.7
Can show us more samples on how to handle incomplete variables from url inputs?
Does it handle POST method? Can show more sample code?
Right now you can't do this:
class MyResource(retwist.ParamResource):
from = retwist.Param()
to = retwist.Param()
... because from
and to
are reserved keyword. Support setting those parameter names somehow!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.