Skip to main content

An opinionated WSGI web framework

Project description

# Goldman

Goldman is an opinionated WSGI framework built on [Falcon](https://github.com/falconry/falcon) with batteries included.

It is [JSON API 1.0](http://jsonapi.org/format/) compliant & most compliments a [CRUD+L](https://en.wikipedia.org/wiki/Create,_read,_update_and_delete) type application currently using a postgres database (referred to as a store), however additional stores are on the roadmap. The framework can be used simply by defining your models with validations & you automatically get:

* Content negotiation
* JSON API query parameters including pagination
* Model based routing
* Serialization / Deserialization to & from REST endpoints
* Serialization / Deserialization to & from the store
* signalling using [Blinker](https://github.com/jek/blinker)
* much much more

### Resource Examples:

Need some examples? How about a few resources like an American & their Truck, you would define your resources like:

```python
import goldman

from app.models import American, Truck


class API(goldman.API):
""" Subclass the goldman.API object & define resources """

RESOURCES = [
goldman.ModelResource(Truck),
goldman.ModelsResource(Truck),
goldman.RelatedResource(Truck),

goldman.ModelResource(American),
goldman.ModelsResource(American),
goldman.RelatedResource(American),
]
```

The above creates API end points supporing all CRUD+L type operations for the American & Truck models. This includes complex query parameters as documented in the JSON API specification. Pagination as well. The `goldman.RelatedResource` is for handling a models relationships if present.

### Model Examples:

To define a model we leverage & extend the awesome [Schematics](https://github.com/schematics/schematics) framework for serialization/deserialization & validation. This is different than (de)serialization over the wire which goldman does as well. From the same examples above the models could look like:

```python

import goldman

from goldman.types import PhoneNumberType, ResourceType, ToManyType, ToOneType
from schematics.types import BooleanType, IntType, StringType


class American(goldman.BaseModel):
""" American model """

RTYPE = 'americans'

"""
The attrs below are the models fields
"""

rid = IntType(
from_rest=False,
rid=True,
)
rtype = ResourceType(RTYPE)

first_name = StringType(
max_length=150,
required=True,
)
last_name = StringType(
max_length=150,
required=True,
)

balding = BooleanType(default=True)
loves_freedom = BooleanType(default=True)
weight = IntType(min_value=250)

# relationships
trucks = ToManyType(
field='owner',
rtype='trucks',
)


class Truck(goldman.BaseModel):
""" Truck model """

RTYPE = 'trucks'

"""
The attrs below are the models fields
"""

rid = IntType(
from_rest=False,
rid=True,
)
rtype = ResourceType(RTYPE)

color = StringType(required=True)
mpg = IntType(max_value=10)

truck_bed_for_lovin = BooleanType(default=True)

# relationships
owner = ToOneType(rtype='americans')
```


The models fields will be cast to the appropriate data types for extra business logic, storage, & transport over the wire. Additionally, validations will be run with JSON API compliant exceptions. An enormous amount of work has been done to ensure strong exception handling with meaningful errors.

### Stuff used to make this:

* [Faclon](https://github.com/falconry/falcon) core WSGI capability
* [Psycopg2](http://initd.org/psycopg/) for postgres integration
* [Blinker](https://github.com/jek/blinker) for signalling events
* [Schematics](http://codemirror.net/) for the awesome object schema layer with validations & a bunch more
* [Python-PhoneNumbers](https://github.com/daviddrysdale/python-phonenumbers) for phone number validations
* [Python-US](https://github.com/unitedstates/python-us) for state validations

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

goldman-0.1.9.tar.gz (52.6 kB view details)

Uploaded Source

File details

Details for the file goldman-0.1.9.tar.gz.

File metadata

  • Download URL: goldman-0.1.9.tar.gz
  • Upload date:
  • Size: 52.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for goldman-0.1.9.tar.gz
Algorithm Hash digest
SHA256 aaff11b6fad110d2c35e6c5ec5892e0d65f4381ddfbaa3cb1010d99837ae6bd9
MD5 52f6efa5fa3e628f2bb491a3c708c581
BLAKE2b-256 c2503cb235f38c0392245ba530fa77bdb4454a0cf4fc3ba779b5140a8bc897da

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page