Giter VIP home page Giter VIP logo

humongolus's Introduction

Persistence and Widget Framework for Python and MongoDB

Google Group: http://groups.google.com/group/humongolus

Features

  • Type Validation
  • Lazy Relationships
  • Full MongoDB Index Support
  • Dirty Updating (only send changes to db)
  • Full Test Suite (97% code coverage)
  • Documentation
  • Exposes default MongoDB cursors
  • Robust Widget System
  • Default HTML Widgets
    • Text
    • Password
    • Checkbox
    • Select
    • MultiSelect
    • TextArea
    • FieldSet
    • Form
  • List validation (len and multiple types)
  • Attribute aliases
  • Dynamic Field Validation
  • Large Collection of Default Field Types
    • Char
    • Integer
    • Float
    • Date
    • TimeStamp
    • DocumentID (pseudo DBRef)
    • AutoIncrement
    • DynamicDocument (pseudo DBRef)
    • Boolean
    • Regex
    • Geo
    • Email
    • Phone
    • Choice Fields (Model, Collection and List)
    • File
  • Endless EmbeddedDocuments
  • Default Created/Modified attributes
  • Easily integrates with Backbone.js or other client side frameworks
  • TODO
    • Tutorials
    • Plugins

Usage also see test.py and tests/test_field.py for more usage examples.

from pymongo.connection import Connection
import logging
import humongolus as orm
import datetime
import humongolus.field as field

conn = Connection()
FORMAT = '%(asctime)-15s %(message)s'
logging.basicConfig(format=FORMAT)
logger = logging.getLogger("humongolus")

orm.settings(logger=logger, db_connection=conn)

class Location(orm.EmbeddedDocument):
    city = field.Char(required=True)
    state = field.Char()

class Job(orm.EmbeddedDocument):
    employer = field.Char()
    title = field.Char(required=True)
    locations = orm.List(type=Location)

class Human(orm.Document):
    _db = "test"
    _collection = "humans"
    human_id = field.AutoIncrement(collection="human")
    name = field.Char(required=True, min=2, max=25)
    age = field.Integer(min=0, max=3000)
    height = field.Float(min=1, max=100000)
    weight = field.Float(min=1, max=30000)
    jobs = orm.List(type=Job)
    genitalia = field.Char()

class Female(Human):
    genitalia = field.Char(default='inny')

class Male(Human):
    genitalia = field.Char(default='outy')

class Car(orm.Document):
    _db = "test"
    _collection = "cars"
    owner = field.DynamicDocument()
    make = field.Char()
    model = field.Char()
    year = field.Date()
    silly_date = field.TimeStamp()    

Human.cars = orm.Lazy(type=Car, key='owner._id')

chris = Male()
chris.name = "Chris"
chris.age = 31
chris.height = 100
chris.weight = 180

job = Job()
job.employer = "Entropealabs"
job.title = "President"

loc = Location()
loc.city = "Chicago"
loc.state = "IL"

job.locations.append(loc)
chris.jobs.append(job)

print chris._json()
    {'jobs': [
        {
            'employer': u'Entropealabs', 
            'locations': [
                {'city': u'Chicago', 'state': u'IL'}
            ], 
            'title': u'President'}
        ], 
        'name': u'Chris', 
        'weight': 180.0, 
        'age': 31, 
        'height': 100.0, 
        'genitalia': u'outy', 
        'human_id': 1328
    }

_id = chris.save()

print _id

    4f36dd48eac0742b92000000

for person in Human.find().sort({"name":-1}):
    print person.name
    print person.created
    print person.modifed
    for job in person.jobs:
        print job.title
        for loc in job.locations:
            print loc.city

car = Car()
car.owner = chris
car.make = "Isuzu"
car.model = "Rodeo"
car.year = datetime.datetime(1998, 1, 1)

print car
    <__main__.Car object at 0x7fe3c9375650>

c_id = car.save()

print car._get("owner")().name
    Chris

humongolus's People

Contributors

entone avatar warchiefx avatar elpargo avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.