Skip to main content
https://travis-ci.org/glorpen/glorpen-di.svg?branch=master https://readthedocs.org/projects/glorpen-di/badge/?version=latest

Another Dependency Injection library for Python.

This package has following three guidelines:

  • any class configured by Container mechanism should not be modified in any way

  • there is no need for external services definition files for Container

  • no Container compiling and service tagging - we have introspection and dynamic language for this task

And so this package provides:

  • no xml configuration

  • no annotations (more cons than pros)

  • no changes to services code

Official repositories

For forking and other funnies.

BitBucket: https://bitbucket.org/glorpen/glorpen-di

GitHub: https://github.com/glorpen/glorpen-di

Supported design patterns

Service instance can be created by:

  • factory service

  • calling class object with arguments

Instance options can be altered by:

  • constructor arguments

  • setters

  • calling methods

  • using configurator service

Each service has defined scope, service cannot request other service from narrower scope.

Injecting services and parameters

from glorpen.di import Container

class MyParamService(object):
    pass

class MyService(object):
    def __init__(self, obj, text, value):
        super(MyService, self).__init__()
        print("service instance: %s" % obj)
        print("container parameter: %s" % text)
        print("provided value: %s" % value)

c = Container()

c.add_service(MyParamService)
c.add_parameter('my-param', "value from container")
c.add_service(MyService).kwargs(obj__svc=MyParamService, text__param="my-param", value="defined value")

c.get(MyService)

Running snippet will print:

service instance: <__main__.MyParamService object at 0x7f2fef6e9828>
container parameter: value from container
provided value: defined value

See https://glorpen-di.readthedocs.io/en/latest/ for code examples and more documentation.

Metadata

Release files for glorpen-di 1.5.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for glorpen-di 1.5.0
File Size Uploaded
glorpen-di-1.5.0.tar.gz 7.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for glorpen-di 1.5.0
File Interpreter ABI Platform
glorpen_di-1.5.0-py2.py3-none-any.whl Python 3, Python 2 none any Details

Total release size: 15.7 kB

Release files / glorpen-di-1.5.0.tar.gz

Download URL glorpen-di-1.5.0.tar.gz
Size 7.1 kB
Tags Source
SHA-256 checksum
How to use checksums
326faf42ff7f680874f8c05030b37211f99479f0657565b861849d1dea91c98e
BLAKE2b-256 checksum
How to use checksums
610ec5ef1ade094da834c053b6252c173a18fb9681240fc79b34b3ff9ffb7113
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.4.2 requests/2.20.0 setuptools/40.5.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.3

Release files / glorpen_di-1.5.0-py2.py3-none-any.whl

Download URL glorpen_di-1.5.0-py2.py3-none-any.whl
Size 8.6 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
a887ada64799f19d3ecadd976c5ff929bbeabf82950176a58e17157574e37b44
BLAKE2b-256 checksum
How to use checksums
3b48428ab08f8d82d7e8a7f752effcc3a5976aef29a12c759e0afe37f8e3cb15
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.4.2 requests/2.20.0 setuptools/40.5.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.3

Release history Release notifications | RSS feed

This release

1.5.0 This release

2 release files

1.4.1

2 release files

1.3.2

2 release files

1.3.1

2 release files

1.3

1 release file

1.2

1 release file

1.1.1

1 release file

1.1

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page