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

A database-agnostic Document-Object Mapper for Python.

Install

$ pip install modular-odm

Example Usage with MongoDB

Defining Models

from modularodm import StoredObject, fields
from modularodm.validators import MinLengthValidator, MaxLengthValidator

class User(StoredObject):
    _meta = {"optimistic": True}
    _id = fields.StringField(primary=True, index=True)
    username = fields.StringField(required=True)
    password = fields.StringField(required=True, validate=[MinLengthValidator(8)])

    def __repr__(self):
        return "<User: {0}>".format(self.username)

class Comment(StoredObject):
    _meta = {"optimistic": True}
    _id = fields.StringField(primary=True, index=True)
    text = fields.StringField(validate=MaxLengthValidator(500))
    user = fields.ForeignField("User", backref="comments")

    def __repr__(self):
        return "<Comment: {0}>".format(self.text)

Setting the Storage Backend

from pymongo import MongoClient
from modularodm import storage

client = MongoClient()
db = client['testdb']
User.set_storage(storage.MongoStorage(db, collection="user"))
Comment.set_storage(storage.MongoStorage(db, collection="comment"))

Creating and Querying

>>> from modularodm.query.querydialect import DefaultQueryDialect as Q
>>> u = User(username="unladenswallow", password="h0lygrai1")
>>> u.save()
>>> comment = Comment(text="And now for something completely different.", user=u)
>>> comment2 = Comment(text="It's just a flesh wound.", user=u)
>>> comment.save()
True
>>> comment2.save()
True
>>> u = User.find_one(Q("username", "eq", "unladenswallow"))
>>> u.comment__comments
[<Comment: And now for something completely different.>, <Comment: It's just a flesh wound.>]
>>> c = Comment.find(Q("text", "startswith", "And now"))[0]
>>> c.text
'And now for something completely different.'

For more information regarding querying syntax, please visit the related readthedocs page at <http://modular-odm.readthedocs.org/en/latest/query_syntax.html>.

Migrations

TODO

Full documentation coming soon.

Development

Tests require nose, invoke, and MongoDB.

Installing MongoDB

If you are on MacOSX with homebrew, run

$ brew update
$ brew install mongodb

Running Tests

To start mongodb, run

$ invoke mongo

Run all tests with

$ invoke test
Release History

Release History

0.3.0

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.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

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
modular_odm-0.3.0-py2.py3-none-any.whl (42.0 kB) Copy SHA256 Checksum SHA256 2.7 Wheel Jul 19, 2016
modular-odm-0.3.0.tar.gz (30.7 kB) Copy SHA256 Checksum SHA256 Source Jul 19, 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