{"id":13813544,"url":"https://github.com/onyb/reobject","last_synced_at":"2025-03-17T03:31:21.224Z","repository":{"id":51020258,"uuid":"79606576","full_name":"onyb/reobject","owner":"onyb","description":"Python without ifs and buts - an ORM layer for Python objects, inspired by Django","archived":false,"fork":false,"pushed_at":"2021-05-26T00:52:15.000Z","size":137,"stargazers_count":81,"open_issues_count":11,"forks_count":8,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-02-27T17:18:02.504Z","etag":null,"topics":["design-patterns","django-orm","models","object-oriented-programming","python"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/onyb.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-01-20T22:36:51.000Z","updated_at":"2024-10-07T09:27:27.000Z","dependencies_parsed_at":"2022-09-17T04:00:26.885Z","dependency_job_id":null,"html_url":"https://github.com/onyb/reobject","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/onyb%2Freobject","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/onyb%2Freobject/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/onyb%2Freobject/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/onyb%2Freobject/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/onyb","download_url":"https://codeload.github.com/onyb/reobject/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243841203,"owners_count":20356443,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["design-patterns","django-orm","models","object-oriented-programming","python"],"created_at":"2024-08-04T04:01:20.964Z","updated_at":"2025-03-17T03:31:20.934Z","avatar_url":"https://github.com/onyb.png","language":"Python","readme":"# reobject\n\n[![Build Status](https://travis-ci.org/onyb/reobject.svg?branch=master)](https://travis-ci.org/onyb/reobject)\n[![PyPI version](https://badge.fury.io/py/reobject.svg)](https://badge.fury.io/py/reobject)\n[![PyPI](https://img.shields.io/pypi/pyversions/reobject.svg)](https://pypi.python.org/pypi/reobject)\n[![codecov](https://codecov.io/gh/onyb/reobject/branch/master/graph/badge.svg)](https://codecov.io/gh/onyb/reobject)\n\n*reobject* is an ORM layer for your objects. It allows you to track and query\nobjects at runtime using a familiar query langauge inspired by Django ORM.\n\n**Note:** *reobject* is **NOT** a database ORM. It keeps track of regular objects in the memory.\n\n\n**This is highly experimental code, and not safe for production.**\n\n### Installation\n\n*reobject* supports Python 3 only.\n\n```sh\npip install reobject\n```\n\n### Example usage\n\n```py3\nfrom reobject.models import Model, Field\n\nclass Book(Model):\n    title = Field()\n    authors = Field()\n    price = Field()\n\n\u003e\u003e\u003e # Create a bunch of objects\n\u003e\u003e\u003e Book(title='The C Programming Language', authors=['Kernighan', 'Ritchie'], price=52)\n\u003e\u003e\u003e Book(title='The Go Programming Language', authors=['Donovan', 'Kernighan'], price=30)\n\n\u003e\u003e\u003e Book.objects.all()  # All books\n[Book(title='The C Programming Language', authors=['Kernighan', 'Ritchie'], price=52),\n Book(title='The Go Programming Language', authors=['Donovan', 'Kernighan'], price=30)]\n\n\u003e\u003e\u003e Book.objects.filter(price__lt=50).values('title')  # Titles of books priced under $50\n[{'title': 'The Go Programming Language'}, {'title': 'The C Programming Language'}]\n\n\u003e\u003e\u003e # Titles of books co-authored by Brian Kernighan\n\u003e\u003e\u003e Book.objects.filter(authors__contains='Kernighan').values_list('title', flat=True)\n['The Go Programming Language', 'The C Programming Language']\n```\n\n### Features\n\n* Elegant data-model syntax inspired by Django ORM.\n* Class-level model fields, out of the box object protocols, pretty reprs; powered by [attrs](http://attrs.org).\n* Advanced query language and chainable querysets. Read the [QuerySet API docs](https://anirudha.co/reobject).\n* Transactions. See [example](tests/unit/test_transaction.py#L7-L13).\n* Many-to-one model relationships. See [example](tests/unit/test_manager.py#L61-L108)\n* [TBA] Attribute indexes for fast lookups.\n\n### Crunching Design Patterns\n\n|  Pattern      |                        Description                       | Pure Python | reobject |\n|:-------------:|:--------------------------------------------------------:|:--------:|:-----------:|\n| Flyweight     | Reuse existing instances of objects with identical state | [Link](https://github.com/faif/python-patterns/blob/master/structural/flyweight.py) | [Link](examples/flyweight.py) |\n| Memento       | Transactional rollback of an object to a previous state in case of an exception | [Link](https://github.com/faif/python-patterns/blob/master/behavioral/memento.py) | [Link](tests/unit/test_transaction.py) |\n| Prototype     | Create clones of a prototype without instantiation       | [Link](https://github.com/faif/python-patterns/blob/master/creational/prototype.py) | [Link](examples/prototype.py) |\n| Singleton     | Restrict a class to provide only a single instance       | [Link](http://python-3-patterns-idioms-test.readthedocs.io/en/latest/Singleton.html) | [Link](examples/singleton.py) |\n| Facade        | Encapsulate a complex subsystem within a single interface object | [Link](https://github.com/faif/python-patterns/blob/master/structural/facade.py) | [Link](examples/facade.py) |\n| Flux          | Event-driven state management inspired by Facebook Flux  | [Link](https://github.com/onyb/python-flux/blob/master/flux/store.py) | [Link](examples/flux.py) |\n\n\u003csub\u003e\u003cb\u003eNote:\u003c/b\u003e Some of the examples above may be inaccurate. The idea is to demonstrate what \u003ci\u003ereobject\u003c/i\u003e is capable of. Pull requests are most welcome.\u003c/sub\u003e\n\n### Contributing\n\nWant to help? You can contribute to the project by:\n\n* Using reobject in your projects, finding bugs, and proposing new features.\n* Sending pull requests with recipes built using reobject.\n* Trying your hand at some [good first bugs](https://github.com/onyb/reobject/issues?q=is%3Aissue+is%3Aopen+label%3Abitesize).\n* Improving test coverage, and writing documentation.\n","funding_links":[],"categories":["Python"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fonyb%2Freobject","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fonyb%2Freobject","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fonyb%2Freobject/lists"}