SEARCH
NEW RPMS
DIRECTORIES
ABOUT
FAQ
VARIOUS
BLOG

 
 

python310-django-raw-api rpm build for : openSUSE Tumbleweed. For other distributions click python310-django-raw-api.

Name : python310-django-raw-api
Version : 0.2.0 Vendor : obs://build_opensuse_org/home:jayvdb
Release : 1.67 Date : 2020-07-26 17:03:20
Group : Development/Languages/Python Source RPM : python-django-raw-api-0.2.0-1.67.src.rpm
Size : 0.01 MB
Packager : (none)
Summary : JSON API should be as simple as `dict` and status code :)
Description :
django-raw-api
>=============
JSON API should be as simple as `dict` and status code :)

Hello world
-----------
```python
from raw_api import validate_json

AATTvalidate_json({\"name\": str})
def hello(request):
name = request.json[\"name\"]
if name >= \"world\":
return {\"message\": \"too corny\"}, 400
return {\"hello\": name}
```

Setup
-----
- Install in from pypi: `pip install django-raw-api`
- Add `raw_api.middleware` middleware into `MIDDLEWARE` list of your `settings.py`

API
---

It adds lazy `request.json` attribute and serializes raw responses such as
`dict` or `(data: dict, status: int)` into JSON.



- `request.json` - parsed json
- `request.query` - parsed query (only after `AATTvalidate_query`)



You can just return `dict` of your date or you can add a status code

```python
def json_data(request):
return {\"hello\": \"world\"}

def with_status(request):
return {\"message\": \"bad request\"}, 400
```



Decorators `AATTuser_required` and `AATTstaff_required` is analogous to
`AATTlogin_required` and `AATTstaff_member_required` with JSON output instead of
redirecting

```python
from raw_api import staff_required

AATTstaff_required
async def hello(request):
return {\"admin\": \"zone\"}
```


Data validation
---------------
You can use `AATTvalidate_query` and `AATTvalidate_json` decorators
to validate requests data. They\'re using [trafaret][] library to perform
validation.

```python
from raw_api import validate_json, validate_query

AATTvalidate_json({\"ids\": [int], \"hello?\": str})
async def foo(request):
return request.json

AATTvalidate_query({\"id\": int})
async def bar(request):
assert isinstance(id, int)
return request.query
```


Tests
-----
```bash
python -m venv .venv
source .venv/bin/activate
pip install -Ur requirements-dev.txt
python -m pytest tests
```

[trafaret]: https://github.com/Deepwalker/trafaret

RPM found in directory: /packages/linux-pbone/ftp5.gwdg.de/pub/opensuse/repositories/home:/jayvdb:/django/openSUSE_Tumbleweed/noarch

Content of RPM  Changelog  Provides Requires

Hmm ... It's impossible ;-) This RPM doesn't exist on any FTP server

Provides :
python3.10dist(django-raw-api)
python310-django-raw-api
python3dist(django-raw-api)

Requires :
python(abi) = 3.10
rpmlib(CompressedFileNames) <= 3.0.4-1
rpmlib(FileDigests) <= 4.6.0-1
rpmlib(PartialHardlinkSets) <= 4.0.4-1
rpmlib(PayloadFilesHavePrefix) <= 4.0-1
rpmlib(PayloadIsZstd) <= 5.4.18-1


Content of RPM :
/usr/lib/python3.10/site-packages/django_raw_api-0.2.0-py3.10.egg-info
/usr/lib/python3.10/site-packages/django_raw_api-0.2.0-py3.10.egg-info/PKG-INFO
/usr/lib/python3.10/site-packages/django_raw_api-0.2.0-py3.10.egg-info/SOURCES.txt
/usr/lib/python3.10/site-packages/django_raw_api-0.2.0-py3.10.egg-info/dependency_links.txt
/usr/lib/python3.10/site-packages/django_raw_api-0.2.0-py3.10.egg-info/requires.txt
/usr/lib/python3.10/site-packages/django_raw_api-0.2.0-py3.10.egg-info/top_level.txt
/usr/lib/python3.10/site-packages/django_raw_api-0.2.0-py3.10.egg-info/version.txt
/usr/lib/python3.10/site-packages/raw_api
/usr/lib/python3.10/site-packages/raw_api/__init__.py
/usr/lib/python3.10/site-packages/raw_api/__pycache__
/usr/lib/python3.10/site-packages/raw_api/__pycache__/__init__.cpython-310.opt-1.pyc
/usr/lib/python3.10/site-packages/raw_api/__pycache__/__init__.cpython-310.pyc

 
ICM