<commit_before># pyramid-jsonapi

Utilities for creating JSON-API apis from a database using the sqlAlchemy ORM and pyramid framework.

## Quick preview

In `views.py`:
```python
import jsonapi
from . import models # Your models module.

jsonapi.create_jsonapi_using_magic_and_pixie_dust(models)

```

Yes, there really is a method called "create_api_using_magic_and_pixie_dust". No, you don't *have* to call it that. If you are feeling more sensible you can use the synonym `autocreate_jsonapi`.

## Installation

Pretty basic right now: copy `jsonapi.py` into your PYTHONPATH or into your project.<commit_msg>Lay out autocreate assumptions.<commit_after># pyramid-jsonapi

Utilities for creating JSON-API apis from a database using the sqlAlchemy ORM and pyramid framework.

## Installation

Pretty basic right now: copy `jsonapi.py` into your PYTHONPATH or into your project.

## Quick preview

In `views.py`:
```python
import jsonapi
# Or 'from . import jsonapi' if you copied jsonapi directly into your project.
from . import models # Your models module.

jsonapi.create_jsonapi_using_magic_and_pixie_dust(models)

```

Yes, there really is a method called "create_api_using_magic_and_pixie_dust". No, you don't *have* to call it that. If you are feeling more sensible you can use the synonym `autocreate_jsonapi()`.

## Usage

### Auto-creating a JSON-API

#### Auto-create Assumptions

1. Your models all inherit from a base class returned by sqlalchemy's `declarative-base()`.
1. Each model has a primary_key called 'id'.
1. You are happy to give your collection end-points the same name as the corresponding database table.
1. You have defined any relationships to exposed via the API using `sqlalchemy.orm.relationship()`.

#### Customising auto-create

### Creating Individual JSON-API Resources from Models

#### Resource Creation On-the-fly

#### Decorating Class Definitions
{'fraction_non_alphanumeric': 0.07944915254237288, 'fraction_numerical': 0.00211864406779661, 'mean_word_length': 4.903125, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2287225', 'n_tokens_mistral': 577, 'n_tokens_neox': 541, 'n_words': 231}