{ "info": { "author": "Mike Thornton", "author_email": "six8@devdetails.com", "bugtrack_url": null, "classifiers": [ "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Natural Language :: English", "Programming Language :: Python", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": "=========\nPolydatum\n=========\n\n.. image:: https://secure.travis-ci.org/plynth/polydatum.png\n :target: http://travis-ci.org/plynth/polydatum\n :alt: Build Status\n\nA Python encapsulated persistence layer for supporting many data access layers.\n\n---------\nChangelog\n---------\n\n0.9.0\n=====\n\n* Added support for Python 3.6+\n\n\n0.8.4\n=====\n\n* Added context middleware\n* Added read only Meta for context\n* First pass at removing LocalProxy magic to make it easier to integrate with other frameworks\n* Made it so you can use simple generator functions for resources\n* Added replace service/resource and made it hard to accidentally register on top of an existing one\n* Simplified exception handling on DataAccessContext so that only in-context or middleware exceptions are raised. Resource exit exceptions are suppressed.\n\nBug Fixes\n---------\n\n* Fixed a bug that prevented usage of a resource in __exit__\n\n----------\nComponents\n----------\n\nDataManager\n===========\n\nThe DataManager is the central object of Polydatum. It is a top-level registry for\nServices, Resources, and Middleware. Typically an application has one DataManager\nper process. The DataManager also manages Contexts and gives access the DAL.\n\n\nContext\n=======\n\nThe Context contains the current state for the active request. It also provides\naccess to Resources. When used in an HTTP framework typically one context is\ncreated at the start of the HTTP request and it ends before the HTTP response\nis sent.\n\nWhen used with task managers such as Celery, the Context is created at the\nstart of a task and ends before the task result is returned.\n\n\nDAL\n===\n\nThe DAL is the \"Data Access Layer\". The DAL is the registry for all Services.\nTo make call a method on a Service, you start with the DAL.\n\n::\n\n result = dal.someservice.somemethod()\n\n\nService\n=======\n\nServices encapsulate business logic and data access. They are the Controller of\nMVC-like applications. Services can be nested within other services.\n\n::\n\n dal.register_services(\n someservice=SomeService().register_services(\n subservice=SubService()\n )\n )\n\n result = dal.someservice.subservice.somemethod()\n\n\nMeta\n====\n\nMeta is data about the context and usually includes things like the active\nuser or HTTP request. Meta is read only and can not be modified inside the\ncontext.\n\n::\n\n class UserService(Service):\n def get_user(self):\n return self._ctx.meta.user\n\n dm = DataManager()\n dm.register_services(users=UserService())\n\n with dm.context(meta={'user': 'bob'}) as ctx:\n assert ctx.dal.test.get_user() == 'bob'\n\n\nResource\n========\n\nResources are on-demand access to data backends such as SQL databases, key\nstores, and blob stores. Resources have a setup and teardown phase. Resources\nare only initialized and setup when they are first accessed within a context.\nThis lazy loading ensures that only the Resources that are needed for a\nparticular request are initialized.\n\nThe setup/teardown phases are particularly good for checking connections out\nfrom a connection pool and checking them back in at the end of the request.\n\n::\n\n def db_pool(context):\n conn = db.checkout_connection()\n yield conn\n db.checkin_connection(conn)\n\n class ItemService(Service):\n def get_item(self, id):\n return self._data_manager.db.query(\n 'SELECT * FROM table WHERE id={id}',\n id=id\n )\n\n dm = DataManager()\n dm.register_services(items=ItemService())\n dm.register_resources(db=db_pool)\n\n with dm.dal() as dal:\n item = dal.items.get_item(1)\n\n\nMiddleware\n==========\n\nMiddleware have a setup and teardown phase for each context. They are\nparticularly useful for managing transactions or error handling.\n\nContext Middleware may only see and modify the Context. With the\nContext, Context Middleware can gain access to Resources.\n\n::\n\n def transaction_middleware(context):\n trans = context.db_resource.new_transaction()\n trans.start()\n try:\n yield trans\n except:\n trans.abort()\n else:\n trans.commit()\n\n dm = DataManager()\n dm.register_context_middleware(transaction_middleware)\n\n\n----------\nPrinciples\n----------\n\n- Methods that get an object should return `None` if an object can not be found.\n- Methods that rely on an object existing to work (such as `create` that relies\n on a parent object) should raise `NotFound` if the parent object does not exist.\n- All data access (SQL, MongoDB, Redis, S3, etc) must be done within a Service.\n\n\n--------------\nConsiderations\n--------------\n\nMiddleware vs Resource\n======================\n\nA Resource is created on demand. It's purpose is to create a needed resource\nfor a request and clean it up when done. It is created inside the context (and possibly\nby middleware). Errors that occur during Resource teardown are suppressed.\n\nMiddleware is ran on every context. It is setup before the context is active and\ntorndown before resources are torndown. It's purpose is to do setup/teardown within\nthe context. Errors that occur in-context are propagated to middleware. Errors that\noccur in middleware are also propagated.\n\n\nTesting\n-------\n\nTo run tests you'll need to install the test requirements:\n\n pip install -e .\n pip install -r src/tests/requirements.txt\n\nRun tests:\n\n cd src/tests && py.test\n\n\n\n", "description_content_type": "text/x-rst", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/plynth/polydatum", "keywords": "orm,persistence", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "polydatum", "package_url": "https://pypi.org/project/polydatum/", "platform": "", "project_url": "https://pypi.org/project/polydatum/", "project_urls": { "Homepage": "https://github.com/plynth/polydatum" }, "release_url": "https://pypi.org/project/polydatum/0.9.0/", "requires_dist": [ "six (==1.12.0)", "werkzeug" ], "requires_python": "", "summary": "An encapsulated persistance layer for Python", "version": "0.9.0" }, "last_serial": 5268349, "releases": { "0.7.3": [ { "comment_text": "", "digests": { "md5": "c39fffc1643d91351b161d787428a94e", "sha256": "f3ed3a0209a3cdc9d790182e5abdd9fc5ffc0286e283b83ff9fa9385a64c8357" }, "downloads": -1, "filename": "polydatum-0.7.3.tar.gz", "has_sig": false, "md5_digest": "c39fffc1643d91351b161d787428a94e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11456, "upload_time": "2014-04-21T22:09:09", "url": "https://files.pythonhosted.org/packages/50/ea/6d5c277603bc225372e70dd3ee2d2d493c1296f2ad77ce161df35532dd2e/polydatum-0.7.3.tar.gz" } ], "0.8.1": [ { "comment_text": "", "digests": { "md5": "762ae8303c1ef5356da8cef25fcce028", "sha256": "2e168abeb35cd415b7b8b78284d9af13519fc232989a4617f64f0dfde9f9f23d" }, "downloads": -1, "filename": "polydatum-0.8.1.tar.gz", "has_sig": false, "md5_digest": "762ae8303c1ef5356da8cef25fcce028", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5379, "upload_time": "2014-08-25T19:33:49", "url": "https://files.pythonhosted.org/packages/a8/24/fcb1c779b553468e921ac98c5ad0593ada02dcc936809aaa98269edcf1bb/polydatum-0.8.1.tar.gz" } ], "0.8.2": [ { "comment_text": "", "digests": { "md5": "6ac781ebf0e044b5db51d0c117f5f569", "sha256": "c4b44dcdd68ca3083793234ec2a0e29c6fbd761aa1c51158afff11c11dcb5787" }, "downloads": -1, "filename": "polydatum-0.8.2.tar.gz", "has_sig": false, "md5_digest": "6ac781ebf0e044b5db51d0c117f5f569", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6446, "upload_time": "2014-12-19T21:05:42", "url": "https://files.pythonhosted.org/packages/a4/fd/cb7220c9034e52d90d8ef165c6f6dea84674f063316af579633b84c9b843/polydatum-0.8.2.tar.gz" } ], "0.8.4": [ { "comment_text": "", "digests": { "md5": "87ea525ab68148af5668b73f1e14df81", "sha256": "f19a44adedf45d58185099408e1b523ad78c2a83b59b0b6e0c58bdc1a8724d08" }, "downloads": -1, "filename": "polydatum-0.8.4.tar.gz", "has_sig": false, "md5_digest": "87ea525ab68148af5668b73f1e14df81", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 14265, "upload_time": "2015-04-05T01:22:38", "url": "https://files.pythonhosted.org/packages/62/8e/ae482442f28a7a640928ad5b647b0302f0da34ae5d28226320aa70d3b6d9/polydatum-0.8.4.tar.gz" } ], "0.8.4rc1": [ { "comment_text": "", "digests": { "md5": "e6f0efe48d1d1df448cc5b27b3cf7d63", "sha256": "b2f7d69d28b593dae5f77cfa2c8d1a251205d879ee9af21f3c380026c54e9337" }, "downloads": -1, "filename": "polydatum-0.8.4rc1.tar.gz", "has_sig": false, "md5_digest": "e6f0efe48d1d1df448cc5b27b3cf7d63", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10640, "upload_time": "2015-01-26T02:23:43", "url": "https://files.pythonhosted.org/packages/cc/01/bbe6a1c22e7c4b79939298ce3ba37128c087953121b06a3fdca4a43d78ef/polydatum-0.8.4rc1.tar.gz" } ], "0.8.4rc2": [ { "comment_text": "", "digests": { "md5": "041eee5760a5ae148786804fe0c9d917", "sha256": "9b31f09b9cea3aec03ab30777dc8d2ac514973c0d5437ec61386cd37c884cb35" }, "downloads": -1, "filename": "polydatum-0.8.4rc2.tar.gz", "has_sig": false, "md5_digest": "041eee5760a5ae148786804fe0c9d917", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 14263, "upload_time": "2015-02-05T21:07:12", "url": "https://files.pythonhosted.org/packages/53/cf/9d1922c7e81fe2ea6a3570118c1601a0ff23c55d5ad83047ded83a0c362b/polydatum-0.8.4rc2.tar.gz" } ], "0.9.0": [ { "comment_text": "", "digests": { "md5": "046d8bd63c4046b59d3c424067208bf0", "sha256": "0d3dedd821cef70a407d529b0a0b24b04b2511d4f976c35f4e09e2f4f56b39b2" }, "downloads": -1, "filename": "polydatum-0.9.0-py3-none-any.whl", "has_sig": false, "md5_digest": "046d8bd63c4046b59d3c424067208bf0", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 13111, "upload_time": "2019-05-14T16:23:30", "url": "https://files.pythonhosted.org/packages/f2/c5/6b7e8cb1dd62df0ad7fdb75235a124bfe0e0582787c8234610c95feabcb9/polydatum-0.9.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "b6a53b4fe8a85faa60b5ef6cd1a7d413", "sha256": "adb74e95cac82ba91d93df01c911f43ea15f0f6887a899fc705482e40c32c9b2" }, "downloads": -1, "filename": "polydatum-0.9.0.tar.gz", "has_sig": false, "md5_digest": "b6a53b4fe8a85faa60b5ef6cd1a7d413", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 15621, "upload_time": "2019-05-14T16:23:31", "url": "https://files.pythonhosted.org/packages/fe/86/d8842a2515f36cf52f2b563a81f1ccd77fd1ff5356406d3d726141856408/polydatum-0.9.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "046d8bd63c4046b59d3c424067208bf0", "sha256": "0d3dedd821cef70a407d529b0a0b24b04b2511d4f976c35f4e09e2f4f56b39b2" }, "downloads": -1, "filename": "polydatum-0.9.0-py3-none-any.whl", "has_sig": false, "md5_digest": "046d8bd63c4046b59d3c424067208bf0", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 13111, "upload_time": "2019-05-14T16:23:30", "url": "https://files.pythonhosted.org/packages/f2/c5/6b7e8cb1dd62df0ad7fdb75235a124bfe0e0582787c8234610c95feabcb9/polydatum-0.9.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "b6a53b4fe8a85faa60b5ef6cd1a7d413", "sha256": "adb74e95cac82ba91d93df01c911f43ea15f0f6887a899fc705482e40c32c9b2" }, "downloads": -1, "filename": "polydatum-0.9.0.tar.gz", "has_sig": false, "md5_digest": "b6a53b4fe8a85faa60b5ef6cd1a7d413", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 15621, "upload_time": "2019-05-14T16:23:31", "url": "https://files.pythonhosted.org/packages/fe/86/d8842a2515f36cf52f2b563a81f1ccd77fd1ff5356406d3d726141856408/polydatum-0.9.0.tar.gz" } ] }