{ "info": { "author": "Adrian Vandier Ast", "author_email": "adrian.vandierast@sewan.fr", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Intended Audience :: Developers", "Intended Audience :: Information Technology", "License :: OSI Approved :: Mozilla Public License 2.0 (MPL 2.0)", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.6" ], "description": "Pysyphe\n=======\n\n.. image:: https://circleci.com/gh/SewanDevs/pysyphe.svg?style=svg\n :target: https://circleci.com/gh/SewanDevs/pysyphe\n\nHelps you create and manage your own rollbackable transactions.\n\nInstallation\n------------\n\n.. code-block:: console\n\n $ pip install pysyphe\n\n\n\nTests\n------\n\nTests should be run under python 2.7 and python 3.6 to tests everything\n\n.. code-block:: console\n\n $ pip install tox\n $ tox -e py27,py36\n\nCoverage reports will be the merge of the coverage for py27 and py36.\n\n\nFeatures\n--------\n\n\n**Rollbackable Actions**\n\nCreate actions and chain them in a pipeline:\n\n.. code-block:: python\n\n\n >>> from pysyphe.actions import ActionsPipeline, Action\n >>> def hello_world():\n ... print(\"Hello world!\")\n ...\n >>> def im_alive():\n ... print(\"I'm Alive!!!\")\n ...\n >>> action1 = Action(hello_world)\n >>> action1.do()\n Hello world!\n >>> action2 = Action(im_alive)\n >>> pipeline = ActionsPipeline([action1, action2])\n >>> pipeline.do()\n Hello world!\n I'm Alive!!!\n\n\nCreate rollback for your actions:\n\n.. code-block:: python\n\n >>> def hello_world():\n ... print(\"Hello world!\")\n ...\n >>> def goodbye_world():\n ... print(\"Goodbye world!\")\n ...\n >>> action = Action(hello_world, goodbye_world)\n >>> action.do()\n Hello world!\n >>> action.undo()\n Goodbye world!\n\n\nRollback pipelines:\n\n.. code-block:: python\n\n >>> def hello_world():\n ... print(\"Hello world!\")\n ...\n >>> def goodbye_world():\n ... print(\"Goodbye world!\")\n ...\n >>> def im_alive():\n ... print(\"I'm Alive!!!\")\n ...\n >>> def im_dead():\n ... print(\"I'm Dead!!!\")\n ...\n >>> pipeline = ActionsPipeline([\n ... Action(im_alive, im_dead),\n ... Action(hello_world, goodbye_world)])\n >>> pipeline.undo() # Nothing to rollback\n >>> pipeline.do()\n I'm Alive!!!\n Hello world!\n >>> pipeline.undo() # Will be done in reverse order.\n Goodbye world!\n I'm Dead!!!\n\n\nRollback only what have been done:\n\n.. code-block:: python\n\n >>> def hello_world():\n ... print(\"Hello world!\")\n ...\n >>> def goodbye_world():\n ... print(\"Goodbye world!\")\n ...\n >>> def im_alive():\n ... print(\"I'm Alive!!!\")\n ...\n >>> def im_dead():\n ... print(\"I'm Dead!!!\")\n ...\n >>> def failure():\n ... raise Exception(\"I broke your pipeline, what are you gonna do?\")\n ...\n >>> pipeline = ActionsPipeline([\n ... Action(hello_world, goodbye_world),\n ... Action(failure, lambda: None), # rollback will be an empty function\n ... Action(im_alive, im_dead)])\n >>> try:\n ... pipeline.do()\n ... except Exception:\n ... pipeline.undo()\n ...\n Hello world!\n Goodbye world!\n\n\nDefine actions with a state:\n\n.. code-block:: python\n\n >>> from pysyphe.actions import statefull_action\n >>> @statefull_action([\"name\"])\n ... def hello(state):\n ... print(\"Hello {}\".format(state[\"name\"]))\n ... state[\"name\"] = \"Dear \" + state[\"name\"]\n ...\n >>> @hello.rollback_action()\n ... def goodbye(state):\n ... print(\"Goodbye {}\".format(state[\"name\"]))\n ...\n >>> action = hello.get_prepared_action(name=\"reader\") # It must be prepared for state to be inialised\n >>> action.do()\n Hello reader\n >>> action.undo()\n Goodbye Dear reader\n >>> action.do()\n Hello Dear reader\n >>> action.do()\n Hello Dear Dear reader\n\n\nChain actions with a state:\n\n.. code-block:: python\n\n >>> @statefull_action([\"name\"])\n ... def hello(state):\n ... print(\"Hello {}\".format(state[\"name\"]))\n ... state[\"name\"] = \"Dear \" + state[\"name\"]\n ...\n >>> @hello.rollback_action()\n ... def goodbye(state):\n ... print(\"Goodbye {}\".format(state[\"name\"]))\n ...\n >>> action = hello.get_prepared_action(name=\"reader\")\n >>> action2 = hello.get_prepared_action(name=action.state.ref_to(\"name\")) # We can access the state of a previous action but read only !\n >>> action3 = hello.get_prepared_action(name=action2.state.ref_to(\"name\"))\n >>> pipeline = ActionsPipeline([action, action2, action3)])\n >>> pipeline.do()\n Hello reader\n Hello Dear reader\n Hello Dear Dear reader\n >>> pipeline.undo()\n Goodbye Dear Dear Dear reader\n Goodbye Dear Dear reader\n Goodbye Dear reader\n >>> pipeline.do()\n Hello Dear reader\n Hello Dear Dear reader\n Hello Dear Dear Dear reader\n >>> pipeline.undo()\n Goodbye Dear Dear Dear Dear reader\n Goodbye Dear Dear Dear reader\n Goodbye Dear Dear reader\n\n\n**Transactions**\n\nCreate transaction handlers and manage them:\n\n.. code-block:: python\n\n >>> from pysyphe.transactions import TransactionHandler, TransactionsManager\n >>> class LoggingTransactionHandler(TransactionHandler):\n ... def __init__(self, name, will_fail):\n ... self.name = name\n ... self.will_fail = will_fail\n ... def begin(self):\n ... print(\"BEGIN {}!\".format(self.name))\n ... def execute(self):\n ... if self.will_fail:\n ... raise Exception(\"Your transaction failed, what are you gonna do?\")\n ... def commit(self):\n ... print(\"COMMIT {}!\".format(self.name))\n ... def rollback(self):\n ... print(\"ROLLBACK {}!\".format(self.name))\n ...\n >>> tran_success = LoggingTransactionHandler(\"first\", will_fail=False)\n >>> tran_fail = LoggingTransactionHandler(\"second\", will_fail=True)\n >>> manager = TransactionsManager()\n >>> manager.add_transaction_handler(tran_success)\n >>> with manager.begin():\n ... manager.execute()\n ... manager.commit()\n ...\n BEGIN first!\n COMMIT first!\n >>> manager = TransactionsManager()\n >>> manager.add_transaction_handler(tran_success)\n >>> manager.add_transaction_handler(tran_fail)\n >>> with manager.begin(): # The transaction manager will rollback all transactions if an exception occurs.\n ... manager.execute()\n ... manager.commit()\n ...\n BEGIN first!\n BEGIN second!\n ROLLBACK first!\n ROLLBACK second!\n Traceback (most recent call last):\n File \"\", line -, in \n File \".../pysyphe/transactions.py\", line -, in execute\n transaction_handler.execute()\n File \"\", line -, in execute\n Exception: Your transaction failed, what are you gonna do?\n\n\nTODOs\n------\n- Generate the documentation\n- Add a \"How-To correctly write unit actions to get the most out of pysyphe\" into the documentation\n\n.. |sewan_logo| image:: http://entreprises.smallizbeautiful.fr/logo/Sewan-Communications.jpg\n :scale: 15\n.. |pipeline_status| image:: https://gitlab.priv.sewan.fr/sophia/pysyphe/badges/master/pipeline.svg\n :target: https://gitlab.priv.sewan.fr/sophia/pysyphe/pipelines\n.. |coverage| image:: https://gitlab.priv.sewan.fr/sophia/pysyphe/badges/master/coverage.svg\n :target: https://gitlab.priv.sewan.fr/sophia/pysyphe/commits/master\n\n\n\n", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/SewanDevs/pysyphe", "keywords": "", "license": "", "maintainer": "", "maintainer_email": "", "name": "pysyphe", "package_url": "https://pypi.org/project/pysyphe/", "platform": "", "project_url": "https://pypi.org/project/pysyphe/", "project_urls": { "Homepage": "https://github.com/SewanDevs/pysyphe" }, "release_url": "https://pypi.org/project/pysyphe/0.10.2/", "requires_dist": null, "requires_python": "", "summary": "Helps you create and manage your own rollbackable transactions.", "version": "0.10.2" }, "last_serial": 4796178, "releases": { "0.10.0": [ { "comment_text": "", "digests": { "md5": "c8650bf8cbda6dab952364b217c22146", "sha256": "4f9e0db5d02f5333b1481d0c29ad733327eb086117b9c3c527d3f718e3eab766" }, "downloads": -1, "filename": "pysyphe-0.10.0-py3-none-any.whl", "has_sig": false, "md5_digest": "c8650bf8cbda6dab952364b217c22146", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 22249, "upload_time": "2018-09-25T16:09:50", "url": "https://files.pythonhosted.org/packages/fa/05/ec2131df89377876f79eb9d6704b09a44575547378ed3ee12af1f023b68f/pysyphe-0.10.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "348b37c7ede8c13fc10d8ba5847eb6af", "sha256": "d97f997aab31c899bac3049aa79f167d262da862b74d1d9bd1170b4c0b93e22b" }, "downloads": -1, "filename": "pysyphe-0.10.0.tar.gz", "has_sig": false, "md5_digest": "348b37c7ede8c13fc10d8ba5847eb6af", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 35091, "upload_time": "2018-09-25T16:09:51", "url": "https://files.pythonhosted.org/packages/4a/99/aa7cdfba9e2e87b65f6b11129ea5e57993d9fbe809b8d4e073667772e502/pysyphe-0.10.0.tar.gz" } ], "0.10.1": [ { "comment_text": "", "digests": { "md5": "274cf0b66f9fdf43950252bbf40b349a", "sha256": "e32d70404489c98d80898e2d759aade39699d6be13a72be77ff6b0ff4ed77f46" }, "downloads": -1, "filename": "pysyphe-0.10.1-py2-none-any.whl", "has_sig": false, "md5_digest": "274cf0b66f9fdf43950252bbf40b349a", "packagetype": "bdist_wheel", "python_version": "py2", "requires_python": null, "size": 28107, "upload_time": "2019-02-08T15:56:38", "url": "https://files.pythonhosted.org/packages/fb/ff/4177d0e7a56627c5cd8716f341f042f7c456ba109ae8e2cb61b3fded9419/pysyphe-0.10.1-py2-none-any.whl" }, { "comment_text": "", "digests": { "md5": "e956b2b589a5b68d937e075dbcfa99c1", "sha256": "ca6b7eac46f29488918f334515e0406c0f137ef30d847d0105be3e9ff9fc1f4e" }, "downloads": -1, "filename": "pysyphe-0.10.1-py3-none-any.whl", "has_sig": false, "md5_digest": "e956b2b589a5b68d937e075dbcfa99c1", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 28107, "upload_time": "2019-02-08T15:55:13", "url": "https://files.pythonhosted.org/packages/6b/d6/987691da6cc36ce5611c09be4c994784f0285bda3a7167136b2ea06b4edb/pysyphe-0.10.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "55addfbeb438551b754798e10a0a3401", "sha256": "530bd0a6b97f65c3abb557dd4624cf6fcfb72fde5f6fc74662be866325636671" }, "downloads": -1, "filename": "pysyphe-0.10.1.tar.gz", "has_sig": false, "md5_digest": "55addfbeb438551b754798e10a0a3401", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 44771, "upload_time": "2019-02-08T15:55:14", "url": "https://files.pythonhosted.org/packages/4b/04/d2b45cb71f171efef978811ba45dd1bf930b36c7cfa18a7f65c509170180/pysyphe-0.10.1.tar.gz" } ], "0.10.1.dev16": [ { "comment_text": "", "digests": { "md5": "f04af80cad8056fd04761d0ccd90c007", "sha256": "14a49de2b6a66dd7c8d9c0eb99a29f5a05614a5b753bb938abfd0cc56804a718" }, "downloads": -1, "filename": "pysyphe-0.10.1.dev16-py2-none-any.whl", "has_sig": false, "md5_digest": "f04af80cad8056fd04761d0ccd90c007", "packagetype": "bdist_wheel", "python_version": "py2", "requires_python": null, "size": 28203, "upload_time": "2019-02-08T15:49:04", "url": "https://files.pythonhosted.org/packages/31/7c/c6b4eaf70a47703393f26c3a69c33efeb9601b858c98eef6a9370a663a6f/pysyphe-0.10.1.dev16-py2-none-any.whl" }, { "comment_text": "", "digests": { "md5": "81b818b15d2d6af4c4417d1f2a2c85c1", "sha256": "417b5302d3731523c7f830edf6fca779ff1d393b909e667bcf2838f2358bbb05" }, "downloads": -1, "filename": "pysyphe-0.10.1.dev16.tar.gz", "has_sig": false, "md5_digest": "81b818b15d2d6af4c4417d1f2a2c85c1", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 42016, "upload_time": "2019-02-08T15:49:06", "url": "https://files.pythonhosted.org/packages/47/d9/71e8dd15da37784098eaf20d8916fe0a598f74879d762e71b2c7d0dd7d04/pysyphe-0.10.1.dev16.tar.gz" } ], "0.10.2": [ { "comment_text": "", "digests": { "md5": "7e285f4ebfc15c06c3c989e738d488f3", "sha256": "b2c510e4074e87ce2bc2697bb8b1a7a3e18230ac7165bafb448e93255fb8a2f3" }, "downloads": -1, "filename": "pysyphe-0.10.2-py2-none-any.whl", "has_sig": false, "md5_digest": "7e285f4ebfc15c06c3c989e738d488f3", "packagetype": "bdist_wheel", "python_version": "py2", "requires_python": null, "size": 28146, "upload_time": "2019-02-08T16:14:07", "url": "https://files.pythonhosted.org/packages/1e/5b/5f146475e760d0655a278993d581281814e9dcca1f4e1cf27777e84ae21d/pysyphe-0.10.2-py2-none-any.whl" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "7e285f4ebfc15c06c3c989e738d488f3", "sha256": "b2c510e4074e87ce2bc2697bb8b1a7a3e18230ac7165bafb448e93255fb8a2f3" }, "downloads": -1, "filename": "pysyphe-0.10.2-py2-none-any.whl", "has_sig": false, "md5_digest": "7e285f4ebfc15c06c3c989e738d488f3", "packagetype": "bdist_wheel", "python_version": "py2", "requires_python": null, "size": 28146, "upload_time": "2019-02-08T16:14:07", "url": "https://files.pythonhosted.org/packages/1e/5b/5f146475e760d0655a278993d581281814e9dcca1f4e1cf27777e84ae21d/pysyphe-0.10.2-py2-none-any.whl" } ] }