This is a pre-production deployment of Warehouse, however changes made here WILL affect the production instance of PyPI.
Latest Version Dependencies status unknown Test status unknown Test coverage unknown
Project Description

Lasso is a small module for Python which allows defining classes with type-checked attributes, conforming to a predetermined schema.

Classes with Lasso schemas can be used to:

  • Type-check object attributes.
  • Validate input data.
  • Deserialize input data to application objects, with direct support for deserializing JSON.
  • Serialize application objects to JSON.

Usage

Define a class, with a schema attached to it used to type-check the attributes:

>>> from lasso import Schemed
>>> class Point(Schemed):
...   __schema__ = { "x": int, "y": int }
...
>>>

Now values can be created, using keyword arguments to set the values of the attributes. Note how the attributes can be accessed normally:

>>> location = Point(x=-3, y=5)
>>> location.x, location.y
(-3, 5)
>>>

Attributes are type-checked:

>>> location.x = 6  # Succeds
>>> location.x = "invalid value"  # Fails
Traceback (most recent call last):
   ...
schema.SchemaError: 'invalid value' should be instance of <class 'int'>
>>> location.x, location.y  # Values remain unchanged
(6, 5)
>>>

Last, but not least, conversion to and from JSON is automatically supported:

>>> json_text = location.to_json(sort_keys=True)
>>> json_text
'{"x": 6, "y": 5}'
>>> value = Point.from_json(json_text)
>>> value.__class__.__name__
'Point'
>>>

Installation

The stable releases are uploaded to PyPI, so you can install them and upgrade using pip:

pip install lasso

Alternatively, you can install development versions —at your own risk— directly from the Git repository:

pip install -e git://github.com/aperezdc/lasso-python

Documentation

The documentation for Lasso is available at:

http://lasso.readthedocs.org/en/latest

Note that the documentation is work in progress. In the meanwhile, you may want to read the source code of the module itself for additional insight, or even better, the code of projects using the module.

Development

If you want to contribute, please use the usual GitHub workflow:

  1. Clone the repository.
  2. Hack on your clone.
  3. Send a pull request for review.

If you do not have programming skills, you can still contribute by reporting issues that you may encounter.

Users

The following projects make use of Lasso :

(If you use it, please do not hesitate in editing this file and add a line to this list.)

Release History

Release History

0.1.0a3

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.1.0a2

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.1.0a1

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.0.5

This version

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.0.4

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.0.3

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.0.2

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.0.1

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

Download Files

Download Files

TODO: Brief introduction on what you do with files - including link to relevant help section.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
lasso-0.0.5.tar.gz (5.0 kB) Copy SHA256 Checksum SHA256 Source Mar 14, 2016

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS HPE HPE Development Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting