Skip to main content

MicroService framework :: Resource

https://travis-ci.org/palankai/pyrs-resource.svg?branch=master https://coveralls.io/repos/palankai/pyrs-resource/badge.svg?branch=master&service=github Documentation Status

Project homepage: https://github.com/palankai/pyrs-resource

Documentation: http://pyrs-resource.readthedocs.org

Issue tracking: https://github.com/palankai/pyrs-resource/issues

What is this package for

In the python world there are many RESTFul framework. Some of them based on Django others are based on Flask. I’ve tried some but I had the feeling, I want to learn one, the use with Django or Flask or even Odoo. And I don’t mention sometimes I found them not flexible enough. So, I’ve decided write my own independent framework what anybody can use in at least the mentioned 3 different worlds.

Nutshell (notice that, it would be the achivement)

from pyrs import resource
from pyrs.resource import GET

class UserResouce:

    @GET(response=ArrayOfUserSchema)
    def get_users(self):
        return User.objects.all()

    @PUT(path='/<int:user_id>', response=UserSchema, request=UserSchema)
    def update_user(self, user_id, body):
        user = get_object_or_404(User, pk=user_id)
        user.name = body['name']
        user.email = body['email']
        user.save()
        return user

app = resource.Application()
app.add('/user', UserResouce)

In this example I’ve shown Django (like) example. The schema is based on pyrs.schema. Even if I tend to use that framework, you would be able to use any other.

Features

  • Using simple classes or even functions (no inheritance)

  • Wrapped error handling, errors can be serialised

  • Extensible API

  • Works with python 2.7, 3.3, 3.4 (tested against these versions)

  • Hooks for extending the dispatching process

Installation

$ pip install pyrs-resource

Dependencies

See requirements.txt for details, but mainly depends on Werkzeug. I’m using that project routing capabilities. Also depends on pyrs.schema as I mentioned in nutshell section.

Important caveats

This code right now really in beta state. I plan to release soon as possible a completely working code, but right now it’s just shaping.

The ecosystem

This work is part of pyrs framework. The complete framework follow the same intention to implement flexible solution.

Contribution

I really welcome any comments! I would be happy if you fork my code or create pull requests. I’ve already really strong opinions what I want to achieve and how, though any help would be welcomed.

Feel free drop a message to me!

Metadata

Release files for pyrs-resource 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyrs-resource 0.2.0
File Size Uploaded Provenance Actions
pyrs-resource-0.2.0.tar.gz 20.0 kB Without provenance Details for pyrs-resource-0.2.0.tar.gz

Release files / pyrs-resource-0.2.0.tar.gz

Download URL pyrs-resource-0.2.0.tar.gz
Size 20.0 kB
Tags Source
SHA-256 checksum
How to use checksums
79800cb8f87ff1374d16c654f41b3ea657c4340a72b4ac50182161f27b995a7a
BLAKE2b-256 checksum
How to use checksums
b229c86b7739e8401c7b8f3918c8fb62e6635c52af80e43b522fc3946213d416
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for pyrs-resource 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.2.0 This release

1 release file No provenance

0.1.0

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page