All Projects → onyb → Reobject

onyb / Reobject

Licence: apache-2.0
Python without ifs and buts - an ORM layer for Python objects, inspired by Django

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Reobject

Herosaver
An educational tool for exporting stl from THREE.js
Stars: ✭ 55 (-29.49%)
Mutual labels:  models
Go Pattern Examples
Examples of implement for awesome go patterns including usual design patterns, in easy understanding examples.
Stars: ✭ 65 (-16.67%)
Mutual labels:  design-patterns
Designpatterns
DesignPatterns samples by csharp on dotnetcore 《大话设计模式》 中设计模式总结/C#(.NETCore)代码
Stars: ✭ 73 (-6.41%)
Mutual labels:  design-patterns
Design Patterns And Principles
A collection of a number of design patterns and principles written in Kotlin
Stars: ✭ 56 (-28.21%)
Mutual labels:  design-patterns
Fxmaterialdesign
JavaFx Material Design Models (UI/UX) 🎉
Stars: ✭ 63 (-19.23%)
Mutual labels:  models
Patterns Demos
Examples of Design Patterns in Java
Stars: ✭ 67 (-14.1%)
Mutual labels:  design-patterns
Pactools
Phase-amplitude coupling (PAC) toolbox
Stars: ✭ 52 (-33.33%)
Mutual labels:  models
Typegoose
Typegoose - Define Mongoose models using TypeScript classes.
Stars: ✭ 1,189 (+1424.36%)
Mutual labels:  models
Torch Models
Stars: ✭ 65 (-16.67%)
Mutual labels:  models
Pypattyrn
A simple library for implementing common design patterns.
Stars: ✭ 1,180 (+1412.82%)
Mutual labels:  design-patterns
Cinemanet
Stars: ✭ 57 (-26.92%)
Mutual labels:  models
Design Pattern Samples App
🎨 Exploring creational,structural and behavioral design patterns using Kotlin
Stars: ✭ 62 (-20.51%)
Mutual labels:  design-patterns
Active attr
What ActiveModel left out
Stars: ✭ 1,155 (+1380.77%)
Mutual labels:  models
Python Design Patterns
Python Design Patterns
Stars: ✭ 55 (-29.49%)
Mutual labels:  design-patterns
Manager
Implementation of the Manager pattern existing in Laravel framework
Stars: ✭ 74 (-5.13%)
Mutual labels:  design-patterns
Business Search App Java
Showcases object oriented programming in Java, Java Swing, Kotlin, and Android
Stars: ✭ 53 (-32.05%)
Mutual labels:  design-patterns
Designpattern
设计模式
Stars: ✭ 66 (-15.38%)
Mutual labels:  design-patterns
Python Dependency Injector
Dependency injection framework for Python
Stars: ✭ 1,203 (+1442.31%)
Mutual labels:  design-patterns
Snail
🎈 🎈 这里有各领域丰富且有用的知识! 🚀 http://note.isnico.com/
Stars: ✭ 74 (-5.13%)
Mutual labels:  design-patterns
Design Patterns
Описание и реализация самых популярных шаблонов проектирования
Stars: ✭ 72 (-7.69%)
Mutual labels:  design-patterns

reobject

Build Status PyPI version PyPI codecov

reobject is an ORM layer for your objects. It allows you to track and query objects at runtime using a familiar query langauge inspired by Django ORM.

Note: reobject is NOT a database ORM. It keeps track of regular objects in the memory.

This is highly experimental code, and not safe for production.

Installation

reobject supports Python 3 only.

pip install reobject

Example usage

from reobject.models import Model, Field

class Book(Model):
    title = Field()
    authors = Field()
    price = Field()

>>> # Create a bunch of objects
>>> Book(title='The C Programming Language', authors=['Kernighan', 'Ritchie'], price=52)
>>> Book(title='The Go Programming Language', authors=['Donovan', 'Kernighan'], price=30)

>>> Book.objects.all()  # All books
[Book(title='The C Programming Language', authors=['Kernighan', 'Ritchie'], price=52),
 Book(title='The Go Programming Language', authors=['Donovan', 'Kernighan'], price=30)]

>>> Book.objects.filter(price__lt=50).values('title')  # Titles of books priced under $50
[{'title': 'The Go Programming Language'}, {'title': 'The C Programming Language'}]

>>> # Titles of books co-authored by Brian Kernighan
>>> Book.objects.filter(authors__contains='Kernighan').values_list('title', flat=True)
['The Go Programming Language', 'The C Programming Language']

Features

  • Elegant data-model syntax inspired by Django ORM.
  • Class-level model fields, out of the box object protocols, pretty reprs; powered by attrs.
  • Advanced query language and chainable querysets. Read the QuerySet API docs.
  • Transactions. See example.
  • Many-to-one model relationships. See example
  • [TBA] Attribute indexes for fast lookups.

Crunching Design Patterns

Pattern Description Pure Python reobject
Flyweight Reuse existing instances of objects with identical state Link Link
Memento Transactional rollback of an object to a previous state in case of an exception Link Link
Prototype Create clones of a prototype without instantiation Link Link
Singleton Restrict a class to provide only a single instance Link Link
Facade Encapsulate a complex subsystem within a single interface object Link Link
Flux Event-driven state management inspired by Facebook Flux Link Link

Note: Some of the examples above may be inaccurate. The idea is to demonstrate what reobject is capable of. Pull requests are most welcome.

Contributing

Want to help? You can contribute to the project by:

  • Using reobject in your projects, finding bugs, and proposing new features.
  • Sending pull requests with recipes built using reobject.
  • Trying your hand at some good first bugs.
  • Improving test coverage, and writing documentation.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].