{ "info": { "author": "Stanislav Prokop", "author_email": "", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 2", "Programming Language :: Python :: 3", "Topic :: Software Development :: Libraries" ], "description": "acetone library\n===============\n\nAbout\n-----\n\nGlue code removal. Acetone is a python library to provide inversion of\ncontrol in situation where other methods are inconvenient or they are\nnot even possible. Or you just like the library.\n\nUsage\n-----\n\nCreate the acetone container somewhere in your application:\n\n.. code:: python\n\n # dependencies.py\n\n from acetone import AcetoneContainer\n\n dependencies = AcetoneContainer()\n # or ioc_container\n # or lord_of_the_dependencies\n # or services\n\nThen use it:\n\n.. code:: python\n\n # class_with_dependency.py\n\n from dependencies import dependencies\n\n class ClassWithSomeDependency(object):\n # you can use strings or types as a key\n dependency = dependencies.Dependency('key')\n\n def use_the_dependency(self):\n self.dependency.dependency_call('argument')\n\nCreate a dependency implementation:\n\n.. code:: python\n\n # dependency_implementation.py\n\n class DependencyImplementation(object):\n def dependency_call(self, argument):\n print(argument)\n\nLater register the implementation and run it!\n\n.. code:: python\n\n # __main__.py\n\n from dependencies import dependencies\n from class_with_dependency import ClassWithSomeDependency\n from dependency_implementation import DependencyImplementation\n\n\n if __name__ == '__main__':\n dependency_implementation = DependencyImplementation()\n dependencies.register_instance('key', dependency_implementation)\n\n instance = ClassWithSomeDependency()\n instance.use_the_dependency()\n\nOr load it from a file:\n\n.. code:: json\n\n [\n {\n \"name\": \"key\",\n \"module\": \"dependency_implementation\",\n \"factory\": \"DependencyImplementation\",\n \"singleton\": true\n }\n ]\n\n.. code:: python\n\n import json\n from dependencies import dependencies\n\n def main():\n with open('configuration.json') as file:\n content = json.load(file)\n dependencies.load_from_dicts(content)\n\n instance = ClassWithSomeDependency()\n instance.use_the_dependency()\n\nFrequently asked questions\n--------------------------\n\nHow fast is it?\n~~~~~~~~~~~~~~~\n\nIt's very fast. It's even faster then a builtin property. The very first\ndependency access requires some initialization for its own setup and\ndependency creation (provided it was not created before), but the\nsubsequent calls are as fast as a member instance access. Dependencies\nuse a descriptor protocol (used by ``@property``), they are initialized\nlazily and once fetched from the container they are set as a normal\ninstance member (class member in case of ClassDependency). This trick is\nused by several frameworks (for example werkzeuq cached\\_property).\n\nHow do I mock it?\n~~~~~~~~~~~~~~~~~\n\nTechnically you can mock it, but I don't think it's necessary. The\ncontainer is simple and well tested. Its purpose is to provide a\nrequested dependency and the dependency can be a mock as well. You can\njust consider it as an essential part of your code and not mock it to\nyour advantage (would you mock properties?).\n\n.. code:: python\n\n class TestXyz(TestCase):\n def tearDown(self):\n container.clean()\n\nTraditionalists wouldn't agree for sure but Python wasn't created by\ntraditionalists in the first place.\n\nAre there any requirements?\n~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nNo external dependencies. For the class used the only requirement is\nthat the class has to be a normal python class with ``__dict__``. In\nother words it can't use ``__slots__``.", "description_content_type": null, "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/prokopst/acetone", "keywords": "dependency injection ioc inversion of control service locator", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "acetone", "package_url": "https://pypi.org/project/acetone/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/acetone/", "project_urls": { "Homepage": "https://github.com/prokopst/acetone" }, "release_url": "https://pypi.org/project/acetone/0.1.0/", "requires_dist": null, "requires_python": "", "summary": "Glue code removal.", "version": "0.1.0" }, "last_serial": 2309858, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "67d2bd9bd70751268525ef0b4d686d60", "sha256": "d297e54cec80df29e790cc8741055c995da93b8e534077554256948edbae37bf" }, "downloads": -1, "filename": "acetone-0.1.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "67d2bd9bd70751268525ef0b4d686d60", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 10361, "upload_time": "2016-08-28T20:13:06", "url": "https://files.pythonhosted.org/packages/6e/a2/f93f818f18b713f6897de0edc405b84048c17e9ef9ebcea01990066cf833/acetone-0.1.0-py2.py3-none-any.whl" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "67d2bd9bd70751268525ef0b4d686d60", "sha256": "d297e54cec80df29e790cc8741055c995da93b8e534077554256948edbae37bf" }, "downloads": -1, "filename": "acetone-0.1.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "67d2bd9bd70751268525ef0b4d686d60", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 10361, "upload_time": "2016-08-28T20:13:06", "url": "https://files.pythonhosted.org/packages/6e/a2/f93f818f18b713f6897de0edc405b84048c17e9ef9ebcea01990066cf833/acetone-0.1.0-py2.py3-none-any.whl" } ] }