Giter Club home page Giter Club logo

prestans's Introduction

Prestans 2.0

A WSGI compliant REST micro-framework.

As of January 2021 prestans is no longer under active development. The intention behind prestans was to bring lightweight, well understood development of RESTful services in Python. That gap has now been filled with many more frameworks with better performance and more modern approaches. Our team thanks you for using prestans in your projects, but recommends you to move to other frameworks.
Latest Version Documentation Status build status

Prestans is a REST micro-framework built right on top of WSGI, designed to perform and co-exists with other middleware and frameworks that you employ. Our target audience are developers building large REST backends for use with pure Ajax (using a framework like Google Closure) or mobile applications. prestans is designed for you to "take as much or as little" as you like.

We recommend you install via pip.

Features:

  • Built right on top of WSGI, designed ground up to cooperate with other frameworks
  • Strong representative of REST philosophies leveraging HTTP headers and verbs
  • Support for multiple dialects, including formalised patterns for binary content
  • Handlers maps HTTP verbs to implemented class methods, complimented with custom request parser and response writer (built on top of WebOb)
  • Unforgivingly strict parsing of requests and responses to ensure data integrity
  • Helper methods to ease transformation of persistent objects to REST responses
  • Pluggable integration to authentication

Prestans ensures that we provide extensive and useful documentation, published at available on Read The Docs. Sphinx source available on Github.

Prestans also offers a set of client side tools to compliment Google Closure.

If you are still wondering prestans is a latin word meaning "excellent, distinguished, imminent."

Getting Help

We recommend the use of our mailing lists as the primary way of getting help:

  • Discuss used for general discussion.
  • Announce used for release and security announcements

Reporting Issues

We prefer the use of our Issue Tracker on Github, to triage feature requests, bug reports.

Before you lodge a lodge a ticket:

  • Seek wisdom from our comprehensive documentation
  • Check to ensure that you are not lodging a duplicate request
  • Search the Web to see that it’s not something to do with your server environment (versions of Web server, WSGI connectors, etc)
  • Ensure that you ask a question on our list, there might already be answer out there or we might have already acknowledged the issue

When reporting issues:

  • Include as much detail as you can about your environment (e.g Server OS, Web Server Version, WSGI connector)
  • Steps that we can use to replicate the bug
  • Share a bit of your application code with us, it goes a long way to replicate issues

prestans's People

Contributors

bradmclain avatar brendon1555 avatar daltonmatos avatar devraj avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

prestans's Issues

Providers and attribute filters to be passed debug flag

Passing the debug flag to provider and attribute filters can allow them to behave differently when in debug mode.

E.g authentication in production could be against LDAP where as during development we can simulate a username and password.

REST service statistics

Async Integration with something like Google analytics, this feature will be implemented in two portions:

  • Logging of API traffic, this will involve logging the accessed pattern along side the accessed URL. To effective create statistics for API we need to log the URL patter of the API end point
  • Logging endpoint URLs with specific IDs or values will make it harder to run statistics, more over the patterns would have to be updated as the API is updated
  • The request router will be able to inform the log of the available / registered URLs.
  • The log would then be processed asynchronously and the data would be pushed to an analytics service like Google Analytics or Piwik for visualisation.

setup.py based install missing subpackages

A standard "python setup.py install" does not install the directories 'ext' or 'tools' or any contained files. I had to manually copy these into the site-packages\prestans directory.

I tested this under a virtualenv setup, both on OSX and Linux (Ubuntu derivative), both Python 2.7.

Use Accept HTTP header to dynamically chooses serializer

Instead of URL separating serialisation format use HTTP request headers

  • Client sends in an Accept Header, if the REST application supports the format it sends back a response
  • REST service can choose not to respond in the requested format (e.g Binary formats)
  • If a format is not supported by the application a standard error message is generated
  • Developer no longer has to register different URLs for separate formats

Questions:

  • Is allowing different formats for request and response a valid interaction?

Consider allowing custom exception handling for REST method

Current thoughts are to allow the developer to handle exceptions thrown from the handler method before the default prestans catches take effect.

This will hopefully allow more meaningful codes/messages in the event of a failure instead of 500 all the time.

This is mainly for app engine when there are common framework exceptions that you want to handle in a fixed way.

Logging error message

File "/Users/bmclain/ETK/Web/meddle/app/prestans/exception.py", line 186, in **str** _loggable_message = ("%s %s" % self._attribute_name) TypeError: not enough arguments for format string Logged from file rest.py, line 1085

Inbound DataAdapter implementation based on AttributeFilter

DataAdapters originally had the idea of adapting rest models to persistent models. It was brought up by @rasjidw on the list.

Major issue was that when copying data back from rest models to persistent models; one typically copied a selection of attributes, depending on the handler action.

Initial ideas to do this was introduction of an configuration per attribute.

AttributeFilter should be able to fill this gap in and allow iteration of selective attributes.

Support for multi-dimensional arrays

Should we do it?

If so, what changes will need to be made to add this functionality.

Further thoughts would probably be best done by addition array classes such as:

  • Array2D
  • Array3D

Anything beyond this is probably superfluous

Rewrite prestans.rest.Resposne by extend webob.Response

  • Writing Cookies is not supported at the moment by prestans.rest.Response
  • Attempt to maintain how applications use the response object
  • The way RESTApplication will write their response will change refer to Webob documentation and source

Add *kawrgs support in AttributeFilter constructor

E.g usage of a custom AttributeFilter instance for request parsers. At the moment the developer has write something like:

filter = AttributeFilter(Model())
filter.attr = False

be nice to support *kawrgs to allow

filter = AttributeFilter(Model(), default_value=False, attr=True)

issue being sub filters cannot be addressed in the constructor.

Response obfuscation/minification

Look into rewriting response bodies with arbitrary keys which can then be substituted by the client.

So something like:
{
"key": "value",
"longer_key": "value2"
}

becomes:
{
"a": "value"
"b": "value2"
}

Initial sample estimates show between 25 to 40 percent size savings are possible.

The substitution dictionary could be passed via HTTP headers.

Revise POST URL parameters and body parsing

An issue was discovered where accessing the URL params of a POST request would then corrupt the body and not allow it to be read.

It has been currently patched by fixing order of operation but this should be revised to check:

  • Is this valid under HTTP?
  • Can it be done differently under webob?
  • Are there other solutions apart from webob?

Todo list for 2.0 release

Features:

  • Restore serialisation code in new Response class
  • Restore request and response parsers
  • Restore attribute filters
  • Restore parameter sets
  • Restore authentication provider
  • Restore authentication decorators
  • Error message serialisation to responses
  • Restore Data Adapters

Testing:

  • Test model parsing

Enhancements:

  • Update regex match for router
  • Throttle provider
  • Cache provider

Documentation

  • Finalise documentation pattern

Consider replacing hasattr in data adapters

Currently data adapters use hasattr() to check for the existence of attributes on the persistent object, however hasattr fails if any Exception is thrown in the property/attribute.

This makes debugging difficult as it can hide errors in properties by treating them as non-existent attributes instead of throwing the correct exception.

An alternative approach would be to use something like the following, explicitly checking for AttributeError:

try:
getattr(someObject, 'someProperty')
except AttributeError:
print "Doesn't exist"
else
print "Exists"

This error is also present in the SQLAlchemy data adapter where it hides any DetachedInstanceError exceptions that are thrown when trying to access out of session objects.

Default values are not present in fields

Default values are not present in fields.

Could possibly be an issue with one of the following:

  • Filters being applied
  • Default only being set when validate is called

Client Data Proxy

Proposed future feature to include a client side data caching proxy.

Would make use of the following technologies:

  • Http ETag
  • HTML5 Local Storage

Implementation to mimic NSURLRequest layer in Cocoa, clients will place requests every time, the cache provider will check if the request was recently placed and return the same result.

Requests have to be able to indicate which methods are cacheable.

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.