Giter Site home page Giter Site logo

pale's People

Contributors

adrianmoses avatar alexnitta avatar awwright avatar rknla avatar soundofjw avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pale's Issues

Implement `route_prefix` for Flask adapter

Currently, if an endpoint has a route URI of /space/endpoint, there is no way of setting a common prefix such as /api/space/endpoint.

This is exemplified on GAE by having contradicting .yaml route that differs from the endpoint URI.

Wrap `uri_for` into context (and/or adaptor)

Right now, uri_for for RelativeLinkField generation must be aware of the underlying adaptor.

It would be ideal to have this method exposed from the context (via context.uri_for or context.adaptor.uri_for) which would call the appropriate underlying method with the correct argument structure.

Add `Field` and `Argument` types to paledoc

For the basics/builtins, these should be pretty straight forward, but since folks will probably implement their own field types and argument types, it probably makes sense to have documentation renderings of the description of the argument outside of the context of how it's used (i.e. right now we have IntegerArgument included with its description within the endpoint doc, but we don't have a general "this argument represents an integer" doc.)

Clean descriptions in JSON docs

Use the clean_description function in pale/docs.py to clean out the descriptions for the JSON documentation returned by generate_json_docs

Pass the request context to the `RelativeLinks` generators

I'm not super confident in how the relative links generators are to begin with, but it's clear that they need a bit more for paginating search results (i.e. the search query parameters should stay the same, but the page or offset should change for the next or previous page).

Two ways of handling this come to mind:

  1. A QueryResult object that contains the original query, and thus can propagate the parameters to the link generator (and therefore also requires no changes to pale), or,
  2. Pull the parameters off of the context in the link generator itself, thus requiring the context.

This prompts a larger question around relative links in general - this is one of the places where there needs to be actual logic in the resource, which makes it more of a module than a manifest document, which feels counter to the spirit of the library in the first place. Another option there is to force the underlying model to provide the link data, which is then implicit in the resource definition..

Add RAML output to pale/doc.py

Add a method generate_raml_docs and associated subprocesses that will generate documentation in RAML format.

RAML spec: [https://github.com/raml-org/raml-spec/blob/master/versions/raml-10/raml-10.md]

Error throwing for missing arguments breaks in webapp2

basically, the PaleBaseResponse inherited by the APIError returns a tuple that works fine for flask, but needs to be run through the response handler for webapp2 in the same way that the actual content response is built on line 287-ish of pale/endpoint.py

Filing this as a TODO note for myself, since i'm not going to fix it right now.

update_date in example_app is causes failure on the 29th, 30th, and 31st of any month

Tests are failing due to update_date in example app.

This is because of how DateTimeModel assumes a day when update_date is called:

if day is None:
   day = self.timestamp.day

In the test, self.timestamp is utcnow, so it could be the 30th.
The tests try to update the month to February (2), which has no 29th, 30th, or 31st.

This highlights how it is not safe to assume a day of None when updating a DateTimeModel.

ERROR: test_successful_post_with_required_params (tests.test_webapp2_adapter.Webapp2AdapterTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/josh/Development/pale/tests/test_flask_adapter.py", line 50, in test_successful_post_with_required_params
    resp = self.app.post('/api/time/parse', {'month': 2})
  File "/Users/josh/Development/pale/venv/lib/python2.7/site-packages/webtest/app.py", line 370, in post
    content_type=content_type)
  File "/Users/josh/Development/pale/venv/lib/python2.7/site-packages/webtest/app.py", line 735, in _gen_request
    expect_errors=expect_errors)
  File "/Users/josh/Development/pale/venv/lib/python2.7/site-packages/webtest/app.py", line 631, in do_request
    self._check_status(status, res)
  File "/Users/josh/Development/pale/venv/lib/python2.7/site-packages/webtest/app.py", line 663, in _check_status
    res)
AppError: Bad response: 500 Internal Server Error (not 200 OK or 3xx redirect for http://localhost/api/time/parse)
<html>
  <head>
    <title>Internal Server Error</title>
    <style>
      body {
        padding: 20px;
        font-family: arial, sans-serif;
        font-size: 14px;
      }
      pre {
        background: #F2F2F2;
        padding: 10px;
      }
    </style>
  </head>
  <body>
    <h1>Internal Server Error</h1>
    <p>The server has either erred or is incapable of performing
    the requested operation.</p>
    <pre>Traceback (most recent call last):
  File &quot;/Users/josh/Development/pale/venv/lib/python2.7/site-packages/webapp2.py&quot;, line 1535, in __call__
    rv = self.handle_exception(request, response, e)
  File &quot;/Users/josh/Development/pale/venv/lib/python2.7/site-packages/webapp2.py&quot;, line 1529, in __call__
    rv = self.router.dispatch(request, response)
  File &quot;/Users/josh/Development/pale/venv/lib/python2.7/site-packages/webapp2.py&quot;, line 1278, in default_dispatcher
    return route.handler_adapter(request, response)
  File &quot;/Users/josh/Development/pale/venv/lib/python2.7/site-packages/webapp2.py&quot;, line 1102, in __call__
    return handler.dispatch()
  File &quot;/Users/josh/Development/pale/venv/lib/python2.7/site-packages/webapp2.py&quot;, line 572, in dispatch
    return self.handle_exception(e, self.app.debug)
  File &quot;/Users/josh/Development/pale/venv/lib/python2.7/site-packages/webapp2.py&quot;, line 570, in dispatch
    return method(*args, **kwargs)
  File &quot;/Users/josh/Development/pale/pale/adapters/webapp2.py&quot;, line 19, in pale_handler
    return pale_endpoint._execute(self.request)
  File &quot;/Users/josh/Development/pale/pale/endpoint.py&quot;, line 170, in _execute
    raise e
ValueError: day is out of range for month
</pre>
  </body>
</html>
-------------------- >> begin captured logging << --------------------
root: INFO: extracted endpoints: [<tests.example_app.api.endpoints.CurrentTimeEndpoint object at 0x106d0eb50>, <tests.example_app.api.endpoints.ParseTimeEndpoint object at 0x106d0ed50>, <tests.example_app.api.endpoints.TimeRangeEndpoint object at 0x106d10050>]
root: INFO: adding endpoint current_time to webapp!
root: INFO: current_time
root: INFO: created route: <Route('/api/time/current', <class 'pale.adapters.webapp2.current_time'>, name='current_time', defaults={}, build_only=False)>
root: INFO: adding endpoint parse_time to webapp!
root: INFO: parse_time
root: INFO: created route: <Route('/api/time/parse', <class 'pale.adapters.webapp2.parse_time'>, name='parse_time', defaults={}, build_only=False)>
root: INFO: adding endpoint time_range_now_plus_duration to webapp!
root: INFO: time_range_now_plus_duration
root: INFO: created route: <Route('/api/time/range', <class 'pale.adapters.webapp2.time_range_now_plus_duration'>, name='time_range_now_plus_duration', defaults={}, build_only=False)>
root: INFO: app router state: <Router([<Route('/api/time/current', <class 'pale.adapters.webapp2.current_time'>, name='current_time', defaults={}, build_only=False)>, <Route('/api/time/parse', <class 'pale.adapters.webapp2.parse_time'>, name='parse_time', defaults={}, build_only=False)>, <Route('/api/time/range', <class 'pale.adapters.webapp2.time_range_now_plus_duration'>, name='time_range_now_plus_duration', defaults={}, build_only=False)>])>
root: ERROR: day is out of range for month
root: ERROR: day is out of range for month
Traceback (most recent call last):
  File "/Users/josh/Development/pale/venv/lib/python2.7/site-packages/webapp2.py", line 1535, in __call__
    rv = self.handle_exception(request, response, e)
  File "/Users/josh/Development/pale/venv/lib/python2.7/site-packages/webapp2.py", line 1529, in __call__
    rv = self.router.dispatch(request, response)
  File "/Users/josh/Development/pale/venv/lib/python2.7/site-packages/webapp2.py", line 1278, in default_dispatcher
    return route.handler_adapter(request, response)
  File "/Users/josh/Development/pale/venv/lib/python2.7/site-packages/webapp2.py", line 1102, in __call__
    return handler.dispatch()
  File "/Users/josh/Development/pale/venv/lib/python2.7/site-packages/webapp2.py", line 572, in dispatch
    return self.handle_exception(e, self.app.debug)
  File "/Users/josh/Development/pale/venv/lib/python2.7/site-packages/webapp2.py", line 570, in dispatch
    return method(*args, **kwargs)
  File "/Users/josh/Development/pale/pale/adapters/webapp2.py", line 19, in pale_handler
    return pale_endpoint._execute(self.request)
  File "/Users/josh/Development/pale/pale/endpoint.py", line 170, in _execute
    raise e
ValueError: day is out of range for month

Better solution for catching OPTIONS requests

  • Currently OPTIONS is manually caught and the response headers are updated.

This is in place of creating an alternate endpoint with the _http_method OPTIONS for all existing endpoints.

Add optional permissions check for doc.py in generate_json_docs

Currently, the generate_json_docs method does not restrict which documentation is returned. Once issue #55 is closed, the new generate_raml_docs method will allow for restricting documentation on endpoints based on the 1) the user's context and 2) whether the endpoint requires permission.

Edit generate_json_docs so that it also allows for the same kind of controlled access.

Tidy up the JSON request body handling

#20 was a bit haphazard, and might require a bit more tidying and thought.

As mentioned in the post-mortem comments there, we need to make sure that we're checking Content-Type, and developing a reasonable strategy for error handling. My knee-jerk reaction is that if the body content isn't parsable by whichever parser we infer from Content-Type, then we should actually raise a 422 Unprocessable Entity here, instead of propagating the request any further down the pipe.

_pre_response_handlers should be called in Exception cases as well

This may be solved more simply in a true pale solution of #13.

Our current issue is that ArgumentErrors call API.UnprocessableEntity (HTTP:422) which bypasses the _pre_response_handlers. This may be the desired behavior, but it leaves us unable to send a CORs header when there are argument errors.

Timestamp Field Rendering

It would be nice to specify a format argument:

  • ISO
  • Custom
  • Timestamp Integer
class TimestampField(StringField):
    """A field for timestamp strings."""
    value_type = 'timestamp'

    # TODO - timestamp field rendering

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.