HomePhabricator

New REST API format

Description

New REST API format

After much feedback and iteration, this is a restructured API. Docs
will be updated with API details in a later commit. I also dropped the
flask restful marshaler, it is too simple for our format. We now use
python's json serializaer + a custom SQLAlchemy object visitor.

Details

Committed
cmatthewsJun 28 2017, 1:45 PM
Parents
rL306595: Some initial docs for the REST API
Branches
Unknown
Tags
Unknown

Event Timeline

Hi Chris, this commit causes servers running from the wsgi script to fail. To reproduce:

lnt create /tmp/test
/tmp/test//lnt.wsgi

wsgi Script prints:

Started file logging.
Logging to : lnt.log
 * Running on HOSTNAME:8000/ (Press CTRL+C to quit)

Visit HOSTNAME:8000 in a browser, browser displays: Internal Server Error The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application.

Detailed error message:

127.0.0.1 - - [11/Jul/2017 16:42:49] "GET / HTTP/1.1" 500 -
Error on request:
Traceback (most recent call last):
  File ".../lib/python2.7/site-packages/werkzeug/serving.py", line 205, in run_wsgi
    execute(self.server.app)
  File ".../lib/python2.7/site-packages/werkzeug/serving.py", line 193, in execute
    application_iter = app(environ, start_response)
  File ".../lib/python2.7/site-packages/flask/app.py", line 1836, in __call__
    return self.wsgi_app(environ, start_response)
  File "/data/work/lnt2017/git/lnt/lnt/server/ui/app.py", line 44, in __call__
    return self.app(environ, start_response)
  File ".../lib/python2.7/site-packages/flask/app.py", line 1813, in wsgi_app
    ctx.push()
  File ".../lib/python2.7/site-packages/flask/ctx.py", line 321, in push
    self.session = self.app.open_session(self.request)
  File ".../lib/python2.7/site-packages/flask/app.py", line 825, in open_session
    return self.session_interface.open_session(self, request)
  File ".../lib/python2.7/site-packages/flask/sessions.py", line 302, in open_session
    s = self.get_signing_serializer(app)
  File ".../lib/python2.7/site-packages/flask/sessions.py", line 299, in get_signing_serializer
    signer_kwargs=signer_kwargs)
  File ".../lib/python2.7/site-packages/itsdangerous.py", line 519, in __init__
    self.is_text_serializer = is_text_serializer(serializer)
  File ".../lib/python2.7/site-packages/itsdangerous.py", line 69, in is_text_serializer
    return isinstance(serializer.dumps({}), text_type)
  File ".../lib/python2.7/site-packages/flask/sessions.py", line 85, in dumps
    return json.dumps(_tag(value), separators=(',', ':'))
  File ".../lib/python2.7/site-packages/flask/json.py", line 126, in dumps
    rv = _json.dumps(obj, **kwargs)
  File ".../lib/python2.7/site-packages/simplejson/__init__.py", line 397, in dumps
    **kw).encode(obj)
TypeError: __init__() got an unexpected keyword argument 'iterable_as_array'

This happens regardless of what data has been imported to the database, and worked prior to revision 306596.