Skip to main content

A framework for supporting MVC and observer patterns in Python

Project description

Orrery

PyPI - Version License Test lint Publish Docs

A framework for supporting MVC and observer patterns in Python

Install

pip install orrery

Update

pip install --update orrery

Documentation

Quick start

See the Tutorial page for more information

Create a model containing an initial value

from orrery.models import ValueModel
my_model = ValueModel(value=5)

Read or set the model value

my_model.value = 6
print(my_model.value)

Constant model:

from orrery.models import ConstantModel
my_model = ConstantModel(value=5)

Model containing a class (i.e. store without copying)

from orrery.models import ClassModel
my_object = MyClass()
my_model = ClassModel(my_object)

Check if a model has been given a value:

print(my_model.has_value())

Observe changes to a model:

class CallbackClass:
    def value_changed(self, model):
        print(f"New value: {model.value}")

callback_class = CallbackClass()
my_model.add_value_changed_listener(callback_class.value_changed)

Create a model which depends on other models:

from orrery.models import DependentModel, ValueModel

model_a = ValueModel(value=2)
model_b = ValueModel(value=3)
sum_model = DependentModel(
    dependencies=dict(model_a=model_a, model_b=model_b), 
    get_result=lambda dependencies: dependencies["model_a"].value + dependencies["model_b"].value
)
print(sum_model.value)

Source code

License

See license file

Copyright

© 2025 Code Choreography Limited

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

orrery-0.1.0.tar.gz (15.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

orrery-0.1.0-py3-none-any.whl (8.0 kB view details)

Uploaded Python 3

File details

Details for the file orrery-0.1.0.tar.gz.

File metadata

  • Download URL: orrery-0.1.0.tar.gz
  • Upload date:
  • Size: 15.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for orrery-0.1.0.tar.gz
Algorithm Hash digest
SHA256 d24ba5073baa28edbb37694762fdfb26d91aa2800a214355d78d420008792f29
MD5 aeadc97fbd3cc039df93edaaafee686c
BLAKE2b-256 727bc9dff8dbc1bc515842796706556faffc4500ca2f1f2eafc8cd49a8fd001d

See more details on using hashes here.

Provenance

The following attestation bundles were made for orrery-0.1.0.tar.gz:

Publisher: publish.yml on CodeChoreography/orrery

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file orrery-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: orrery-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 8.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for orrery-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 47462aa87a9fb47ebb15177837bfdbd27a231ffad66ce98e4a8542d636955741
MD5 38b53b51eb91578efe77aa7ce4e46265
BLAKE2b-256 2e236f6dd62a258c5e7f6f9d1dccf679a9a83fa8f4db7632eac56b2c9e36f93a

See more details on using hashes here.

Provenance

The following attestation bundles were made for orrery-0.1.0-py3-none-any.whl:

Publisher: publish.yml on CodeChoreography/orrery

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page