Skip to content

Commit

Permalink
Update container examples with namedtuples
Browse files Browse the repository at this point in the history
  • Loading branch information
rmk135 committed Jun 8, 2016
1 parent 14ca565 commit 8d1ae1a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 21 deletions.
18 changes: 3 additions & 15 deletions examples/containers/declarative_injections.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,14 @@
"""Declarative IoC container's provider injections example."""

import sqlite3
import collections

import dependency_injector.containers as containers
import dependency_injector.providers as providers


class UsersService(object):
"""Users service, that has dependency on database."""

def __init__(self, db):
"""Initializer."""
self.db = db


class AuthService(object):
"""Auth service, that has dependencies on users service and database."""

def __init__(self, db, users_service):
"""Initializer."""
self.db = db
self.users_service = users_service
UsersService = collections.namedtuple('UsersService', ['db'])
AuthService = collections.namedtuple('AuthService', ['db', 'users_service'])


class Services(containers.DeclarativeContainer):
Expand Down
10 changes: 4 additions & 6 deletions examples/containers/dynamic_runtime_creation.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
"""Creation of dynamic container based on some configuration example."""

import collections

import dependency_injector.containers as containers


# Defining several example services:
class UsersService(object):
"""Example users service."""


class AuthService(object):
"""Example auth service."""
UsersService = collections.namedtuple('UsersService', [])
AuthService = collections.namedtuple('AuthService', [])


def import_cls(cls_name):
Expand Down

0 comments on commit 8d1ae1a

Please sign in to comment.