From 682c4498ca9db7b5134236cb6d7d85974399ba9f Mon Sep 17 00:00:00 2001 From: Roman Mogilatov Date: Mon, 19 Oct 2015 10:31:53 +0300 Subject: [PATCH] Remove old catalog bundles example --- examples/catalogs/bundles.py | 61 ------------------------------------ 1 file changed, 61 deletions(-) delete mode 100644 examples/catalogs/bundles.py diff --git a/examples/catalogs/bundles.py b/examples/catalogs/bundles.py deleted file mode 100644 index b6d6c8e2..00000000 --- a/examples/catalogs/bundles.py +++ /dev/null @@ -1,61 +0,0 @@ -"""Catalog bundles example.""" - -import dependency_injector as di - - -# Declaring example services catalog: -class Services(di.AbstractCatalog): - """Example catalog of service providers.""" - - users = di.Provider() - - auth = di.Provider() - - photos = di.Provider() - - -# Declaring example base class for some web views: -class BaseWebView(object): - """Example base class of web view.""" - - def __init__(self, services): - """Initializer. - - :type services: Services - :param services: Bundle of service providers - """ - self.services = services - - -# Declaring several example web views: -class AuthView(BaseWebView): - """Example auth web view.""" - - -class PhotosView(BaseWebView): - """Example photo processing web view.""" - -# Creating example views with appropriate service provider bundles: -auth_view = AuthView(Services.Bundle(Services.users, - Services.auth)) -photos_view = PhotosView(Services.Bundle(Services.users, - Services.photos)) - -# Making some asserts: -assert auth_view.services.users is Services.users -assert auth_view.services.auth is Services.auth -try: - auth_view.services.photos -except di.Error: - # `photos` service provider is not in scope of `auth_view` services bundle, - # so `di.Error` will be raised. - pass - -assert photos_view.services.users is Services.users -assert photos_view.services.photos is Services.photos -try: - photos_view.services.auth -except di.Error as exception: - # `auth` service provider is not in scope of `photo_processing_view` - # services bundle, so `di.Error` will be raised. - pass