{ "info": { "author": "Yujan Shrestha", "author_email": "yshrestha88@gmail.com", "bugtrack_url": null, "classifiers": [], "description": "===============================\n Python Service Locator v 0.1.3\n===============================\n\n- The service locator pattern is a very simple but useful pattern that helps you remove glue code from application code.\n- Decoupling the wiring of dependencies (glue code) can reduce your lines of code significantly and encourages loose coupling.\n- This allows you to depend on abstractions rather than on concretions, it makes adding additional\n functionality to your application much easier.\n- Configuration xml files are not pythonic and are often overcomplicated, class decorators are used instead.\n- Concrete service implementations should be placed in a services folder. All services subfolders will be discovered using\n discover_services function and all containing modules will be auto-loaded.\n- All services will be instantiated by the service locator as a singleton.\n\n\nUsage\n-----\n\nPlease see test/integration/test.py for a sample project. Suppose you have an abstract service class that looks like this:\n\n.. code-block:: python\n\n #mime_recognizer_service.py\n class MIMERecognizerService(object):\n def recognizes_extension(self, extension):\n pass\n\n def get_MIME_type(self):\n pass\n\nRegister a service like this:\n\n.. code-block:: python\n\n #pdf_recognizer.py\n from servicelocator.service_discoverer import discover_services\n\n @service_provider(MIMERecognizerService)\n class PDFRecognizer(MIMERecognizerService):\n def recognizes_extension(self, extension):\n return extension == \".pdf\"\n\n def get_MIME_type(self):\n return \"application/pdf\"\n \n\nYou can register as many services and service providers as you like. When you retrieve all MIMERecognizerServices using the \nlookup_all function, one of the results in the list will be a PDFRecognizer() instance.\n\nIn order for the service discovery process to find the PDFRecognizer, you need to place it in a services folder. Your \ndirectory structure might look something like this (__init__.py's removed for demo purposes):\n\n::\n\n -root/\n -main.py\n -mime_recognizers/\n -mime_recognizer_service.py\n -services/\n -pdf_recognizer.py\n -file_openers/\n -file_opener_service.py\n -services/\n -pdf_opener.py\n \nYou discover services like this:\n\n.. code-block:: python\n\n from servicelocator.service_discoverer import discover_services\n\n discover_services()\n \nAnd that's it. The discover_services will walk the project directory tree and import all python modules inside services folders.\n\nTo retrieve service providers for a service, use the lookup functions like this:\n\n.. code-block:: python\n\n from servicelocator.lookup import global_lookup\n\n MIMERecognizers = global_lookup.lookup_all(MIMERecognizerService)\n\nThis will get all concrete implementations of the MIMERecognizerService but the we do not need to know about the\nexistence of any of these concrete implementations. Adding extra functionality is as simple as dropping a file inside a\nservices directory, no additional code is necessary. This makes adding new service providers in a loosely coupled way very easy .\n\nAnd if you know there is only one implementation of the service:\n\n.. code-block:: python\n\n from servicelocator.lookup import global_lookup\n\n MIMERecognizer = global_lookup.lookup(MIMERecognizerService)", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/eipiconsulting/service-locator", "keywords": null, "license": "Apache License", "maintainer": null, "maintainer_email": null, "name": "service-locator", "package_url": "https://pypi.org/project/service-locator/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/service-locator/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/eipiconsulting/service-locator" }, "release_url": "https://pypi.org/project/service-locator/0.1.3/", "requires_dist": null, "requires_python": null, "summary": "Dead simple python service locator", "version": "0.1.3" }, "last_serial": 837480, "releases": { "0.1.3": [ { "comment_text": "", "digests": { "md5": "07dd61a56d55f81ba097e2a372432b61", "sha256": "ccbffd9329a2b16cc7fad01c2d26d0871778288e2cb0ef36996bd20f0731081d" }, "downloads": -1, "filename": "service-locator-0.1.3.tar.gz", "has_sig": false, "md5_digest": "07dd61a56d55f81ba097e2a372432b61", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 2722, "upload_time": "2013-08-11T09:14:17", "url": "https://files.pythonhosted.org/packages/86/c2/5d87344e985d325db2c250f24bce93c005f62c25fc27363a38241a2f1027/service-locator-0.1.3.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "07dd61a56d55f81ba097e2a372432b61", "sha256": "ccbffd9329a2b16cc7fad01c2d26d0871778288e2cb0ef36996bd20f0731081d" }, "downloads": -1, "filename": "service-locator-0.1.3.tar.gz", "has_sig": false, "md5_digest": "07dd61a56d55f81ba097e2a372432b61", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 2722, "upload_time": "2013-08-11T09:14:17", "url": "https://files.pythonhosted.org/packages/86/c2/5d87344e985d325db2c250f24bce93c005f62c25fc27363a38241a2f1027/service-locator-0.1.3.tar.gz" } ] }