{ "info": { "author": "Martin Aspeli", "author_email": "optilude@gmail.com", "bugtrack_url": null, "classifiers": [ "License :: OSI Approved :: BSD License", "Programming Language :: Python", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7" ], "description": "========================\ncollective.monkeypatcher\n========================\n\n.. image:: https://travis-ci.com/plone/collective.monkeypatcher.svg?branch=master\n :target: https://travis-ci.com/plone/collective.monkeypatcher\n\n.. image:: https://coveralls.io/repos/github/zopefoundation/collective.monkeypatcher/badge.svg?branch=master\n :target: https://coveralls.io/github/zopefoundation/collective.monkeypatcher?branch=master\n\n.. image:: https://img.shields.io/pypi/v/collective.monkeypatcher.svg\n :target: https://pypi.org/project/collective.monkeypatcher/\n :alt: Current version on PyPI\n\n.. image:: https://img.shields.io/pypi/pyversions/collective.monkeypatcher.svg\n :target: https://pypi.org/project/collective.monkeypatcher/\n :alt: Supported Python versions\n\n\nIntroduction\n============\n\nSometimes, a monkey patch is a necessary evil.\n\nThis package makes it easier to apply a monkey patch during Zope startup.\nIt uses the ZCML configuration machinery to ensure that patches are loaded\n\"late\" in the startup cycle, so that the original code has had time to be\nfully initialised and configured. This is similar to using the `initialize()`\nmethod in a product's __init__.py, except it does not require that the package\nbe a full-blown Zope product with a persistent Control_Panel entry.\n\n\nInstallation\n============\n\nTo install `collective.monkeypatcher` into the global Python environment\n(or a working environment), using a traditional Zope instance, you can do this:\n\n* When you're reading this you have probably already run\n ``pip install collective.monkeypatcher``.\n\n* Create a file called ``collective.monkeypatcher-configure.zcml`` in the\n ``/path/to/instance/etc/package-includes`` directory. The file\n should only contain this::\n\n \n\n\nAlternatively, if you are using `zc.buildout` and the\n`plone.recipe.zope2instance` recipe to manage your project, you can do this:\n\n* Add ``collective.monkeypatcher`` to the list of eggs to install, e.g.::\n\n [buildout]\n ...\n eggs =\n ...\n collective.monkeypatcher\n\n* Tell the plone.recipe.zope2instance recipe to install a ZCML slug::\n\n [instance]\n recipe = plone.recipe.zope2instance\n ...\n zcml =\n collective.monkeypatcher\n\n* Re-run buildout, e.g. with::\n\n $ ./bin/buildout\n\nYou can skip the ZCML slug if you are going to explicitly include the package\nfrom another package's configure.zcml file.\n\n\nApplying a monkey patch\n=======================\n\nHere's an example::\n\n \n\n \n\n \n\n \n\nIn this example, we patch Plone's CatalogTool's searchResults() function,\nreplacing it with our own version in catalog.py. To patch a module level\nfunction, you can use `module` instead of `class`. The original class and\nfunction/method name and the replacement symbol will be checked to ensure\nthat they actually exist.\n\nIf patching happens too soon (or too late), use the `order` attribute to\nspecify a higher (later) or lower (earlier) number. The default is 1000.\n\nBy default, `DocFinderTab `_\nand other TTW API browsers will emphasize the monkey patched methods/functions,\nappending the docstring with \"Monkey patched with 'my.monkeypatched.function'\".\nIf you don't want this, you could set the `docstringWarning` attribute to\n`false`.\n\nIf you want to do more than just replace one function with another, you can\nprovide your own patcher function via the `handler` attribute. This should\nbe a callable like::\n\n def apply_patch(scope, original, replacement):\n ...\n\nHere, `scope` is the class/module that was specified. `original` is the string\nname of the function to replace, and `replacement` is the replacement function.\n\nFull list of options:\n\n- ``class`` The class being patched\n- ``module`` The module being patched (see `Patching module level functions`_)\n- ``handler`` A function to perform the patching. Must take three parameters: class/module, original (string), and replacement\n- ``original`` Method or function to replace\n- ``replacement`` Method or function to replace with\n- ``preservedoc`` Preserve docstrings?\n- ``preserveOriginal`` Preserve the original function so that it is reachable view prefix _old_. Only works for default handler\n- ``preconditions`` Preconditions (multiple, separated by space) to be satisified before applying this patch. Example: Products.LinguaPlone-=1.4.3 or Products.TextIndexNG3+=3.3.0\n- ``ignoreOriginal`` Ignore if the orginal function isn't present on the class/module being patched\n- ``docstringWarning`` Add monkey patch warning in docstring\n- ``description`` Some comments about your monkey patch\n- ``order`` Execution order\n\nHandling monkey patches events\n==============================\n\nApplying a monkey patch fires an event. See the `interfaces.py` module. If you\nto handle such event add this ZCML bunch::\n\n ...\n \n ...\n\nAnd add such Python::\n\n def myHandler(event):\n \"\"\"see collective.monkeypatcher.interfaces.IMonkeyPatchEvent\"\"\"\n ...\n\n\nPatching module level functions\n===============================\n\n\n.. ATTENTION:: Be aware that patching module level functions will likely not work.\n\n\nIf you want to patch the method `do_something` located in `patched.package.utils` which is imported in a package like this\n\n::\n\n from patched.package.utils import do_something\n\nthe reference to this function is loaded *before* `collective.monkeypatcher` will patch the original method.\n\nSee also `this related thread on the plone mailing list `_.\n\nWorkaround\n----------\n\n\nDo the patching in `__init__.py` of your package::\n\n from patched.package import utils\n\n def do_it_different():\n return 'foo'\n\n utils.do_something = do_it_different\n\nChangelog\n=========\n\n1.2 (2018-12-10)\n----------------\n\nNew features:\n\n- Include installation instructions in the README.\n\n- Update test infrastructure.\n\n\n1.1.6 (2018-10-31)\n------------------\n\nBug fixes:\n\n- Prepare for Python 2 / 3 compatibility\n [frapell]\n\n\n1.1.5 (2018-06-18)\n------------------\n\nBug fixes:\n\n- Fix import for Python 3 in the tests module\n [ale-rt]\n\n\n1.1.4 (2018-04-08)\n------------------\n\nBug fixes:\n\n- Fix import for Python 3\n [pbauer]\n\n\n1.1.3 (2017-11-26)\n------------------\n\nNew features:\n\n- Document possible problems when patching module level functions\n [frisi]\n\n\n1.1.2 (2016-08-10)\n------------------\n\nFixes:\n\n- Use zope.interface decorator.\n [gforcada]\n\n\n1.1.1 (2015-03-27)\n------------------\n\n- Fix typo.\n [gforcada]\n\n\n1.1 - 2014-12-10\n----------------\n\n* Fix the case where the replacement object does not have a __module__\n attribute (see https://github.com/plone/collective.monkeypatcher/pull/3).\n [mitchellrj, fRiSi]\n\n1.0.1 - 2011-01-25\n------------------\n\n* Downgrade standard log message to debug level.\n [hannosch]\n\n1.0 - 2010-07-01\n----------------\n\n* Avoid a zope.app dependency.\n [hannosch]\n\n* Added new parameter preconditions that only patches if preconditions are met\n like version of a specific package.\n [spamsch]\n\n* Added new parameter preserveOriginal. Setting this to true makes it possible\n to access the patched method via _old_``name of patched method``\n [spamsch]\n\n1.0b2 - 2009-06-18\n------------------\n\n* Add the possibility to ignore the error if the original function isn't\n present on the class/module being patched\n [jfroche]\n\n* Check if the docstring exists before changing it\n [jfroche]\n\n* Add buildout.cfg for test & test coverage\n [jfroche]\n\n1.0b1 - 2009-04-17\n------------------\n\n* Fires an event when a monkey patch is applied. See interfaces.py.\n [glenfant]\n\n* Added ZCML attributes \"docstringWarning\" and \"description\".\n [glenfant]\n\n* Added unit tests.\n [glenfant]\n\n1.0a1 - 2009-03-29\n------------------\n\n* Initial release\n [optilude]\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/plone/collective.monkeypatcher", "keywords": "zope monkey patch", "license": "BSD", "maintainer": "", "maintainer_email": "", "name": "collective.monkeypatcher", "package_url": "https://pypi.org/project/collective.monkeypatcher/", "platform": "", "project_url": "https://pypi.org/project/collective.monkeypatcher/", "project_urls": { "Homepage": "https://github.com/plone/collective.monkeypatcher" }, "release_url": "https://pypi.org/project/collective.monkeypatcher/1.2/", "requires_dist": [ "setuptools", "six", "zope.component; extra == 'test'", "zope.configuration; extra == 'test'" ], "requires_python": "", "summary": "Support for applying monkey patches late in the startup cycle by using ZCML configuration actions", "version": "1.2" }, "last_serial": 4583580, "releases": { "1.0": [ { "comment_text": "", "digests": { "md5": "050fe8519aa124188594690e2bcb7bef", "sha256": "91f59c0d57d279bddc5cf623450b0aa79679b0923a17eee410317729be6e669e" }, "downloads": -1, "filename": "collective.monkeypatcher-1.0.zip", "has_sig": false, "md5_digest": "050fe8519aa124188594690e2bcb7bef", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 19759, "upload_time": "2010-07-01T17:57:09", "url": "https://files.pythonhosted.org/packages/b5/b7/eed13055e646ab27dbd0744bf572099c9e604073b0e008029635de1de4b9/collective.monkeypatcher-1.0.zip" } ], "1.0.1": [ { "comment_text": "", "digests": { "md5": "4d4f20f9b8bb84b24afadc4f56f6dc2c", "sha256": "0bcebaaba4bbae57f2022afdb48a24ecda8e7ce5677b196a5512afb4b7a71fe2" }, "downloads": -1, "filename": "collective.monkeypatcher-1.0.1.zip", "has_sig": false, "md5_digest": "4d4f20f9b8bb84b24afadc4f56f6dc2c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 20012, "upload_time": "2011-01-25T21:35:27", "url": "https://files.pythonhosted.org/packages/83/91/bf4e5ab34050be69416f6bb9b5bd8a5c67ed45439e804148bd4ccce9e0e8/collective.monkeypatcher-1.0.1.zip" } ], "1.0a1": [ { "comment_text": "", "digests": { "md5": "0dd53b7cc65af59240d86e8e6a33c40a", "sha256": "9cef16becbd26e825abff8c2b79c6295e779888f09e66c87b08b3409f4279d92" }, "downloads": -1, "filename": "collective.monkeypatcher-1.0a1.tar.gz", "has_sig": false, "md5_digest": "0dd53b7cc65af59240d86e8e6a33c40a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4159, "upload_time": "2009-03-29T19:03:49", "url": "https://files.pythonhosted.org/packages/93/b7/eea6157378b13d07ac578ace3bde4975e98985dd0c24e57c767b8a36a501/collective.monkeypatcher-1.0a1.tar.gz" } ], "1.0b1": [ { "comment_text": "", "digests": { "md5": "c4d741e6940ab4b9c5c7e09c1e86169d", "sha256": "52ab4dbf761a56c5f608118c109995d6a8cbc4b006e21a0bf091cd4c2dd0a41f" }, "downloads": -1, "filename": "collective.monkeypatcher-1.0b1.tar.gz", "has_sig": false, "md5_digest": "c4d741e6940ab4b9c5c7e09c1e86169d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6566, "upload_time": "2009-04-17T10:14:19", "url": "https://files.pythonhosted.org/packages/5b/46/46ea02922fd548f4b38ca6e47960b1958092e94bfcb722cbe7ed0d45db9f/collective.monkeypatcher-1.0b1.tar.gz" } ], "1.0b2": [ { "comment_text": "", "digests": { "md5": "eed62aed7422af2c54aecd64be69432e", "sha256": "c7cb6769f0fdcb78fbbc2167fe6034df9c3ca7c976926199c49623d828e05071" }, "downloads": -1, "filename": "collective.monkeypatcher-1.0b2.tar.gz", "has_sig": false, "md5_digest": "eed62aed7422af2c54aecd64be69432e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8221, "upload_time": "2009-06-18T14:34:16", "url": "https://files.pythonhosted.org/packages/6b/c1/8418eaaeb32389009547833258f538cca37421557c2fc28f89b34abc9c66/collective.monkeypatcher-1.0b2.tar.gz" } ], "1.1": [ { "comment_text": "", "digests": { "md5": "933cc3ffba1fcfff21875db93e402e12", "sha256": "cb6c7880530f8a3ab3287f4201959442352a5bb1b87dd3fe155de57bfc271d90" }, "downloads": -1, "filename": "collective.monkeypatcher-1.1.zip", "has_sig": false, "md5_digest": "933cc3ffba1fcfff21875db93e402e12", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 20157, "upload_time": "2014-12-10T15:09:34", "url": "https://files.pythonhosted.org/packages/e6/31/1e6b09b0517801d042f23371155e77e0946aaa1e41122873acc616a2052b/collective.monkeypatcher-1.1.zip" } ], "1.1.1": [ { "comment_text": "", "digests": { "md5": "d9ebb0d2a5a4f0f03b0bc21f0c40f531", "sha256": "54ce01111d959a5db1183ce025bfcf0f16fb2af8ba599ef098156a34c3ab4073" }, "downloads": -1, "filename": "collective.monkeypatcher-1.1.1.zip", "has_sig": false, "md5_digest": "d9ebb0d2a5a4f0f03b0bc21f0c40f531", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 20547, "upload_time": "2015-03-27T08:45:55", "url": "https://files.pythonhosted.org/packages/33/63/3e7c43d923ab00d6ea3bbad6b85761d4826c563ca76725e34a1049b753ae/collective.monkeypatcher-1.1.1.zip" } ], "1.1.2": [ { "comment_text": "", "digests": { "md5": "3deb28bb8c5bf11c7aa49bb1ebb274cf", "sha256": "2a6b19d204a22235b23201d47f59e37cb2adc7ccc7c700630659a2c2576b3fc2" }, "downloads": -1, "filename": "collective.monkeypatcher-1.1.2.tar.gz", "has_sig": false, "md5_digest": "3deb28bb8c5bf11c7aa49bb1ebb274cf", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10135, "upload_time": "2016-08-10T21:29:37", "url": "https://files.pythonhosted.org/packages/45/75/01e1e4cd8b13ffe3081a0b8cb45e3f1df49c93389a128dd6cee567666dfb/collective.monkeypatcher-1.1.2.tar.gz" } ], "1.1.3": [ { "comment_text": "", "digests": { "md5": "42f5614ed1dc05d38850b6673e276338", "sha256": "185c70af936d77474caf1ab7265f62b2e919921ec7739e1e12599639e19bab34" }, "downloads": -1, "filename": "collective.monkeypatcher-1.1.3.tar.gz", "has_sig": false, "md5_digest": "42f5614ed1dc05d38850b6673e276338", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11805, "upload_time": "2017-11-26T16:37:02", "url": "https://files.pythonhosted.org/packages/e3/b7/e522d00308851d9b9496614a2ef4d0db5d576632578d9b36b06e09bec80a/collective.monkeypatcher-1.1.3.tar.gz" } ], "1.1.4": [ { "comment_text": "", "digests": { "md5": "f33eb9c7be1d621e34f715c55cb12e40", "sha256": "6dcb9f3197fb31aa1342e95f3070a5e5424946244de2f96e706586b62f59ca01" }, "downloads": -1, "filename": "collective.monkeypatcher-1.1.4-py2-none-any.whl", "has_sig": false, "md5_digest": "f33eb9c7be1d621e34f715c55cb12e40", "packagetype": "bdist_wheel", "python_version": "py2", "requires_python": null, "size": 14834, "upload_time": "2018-04-08T18:44:58", "url": "https://files.pythonhosted.org/packages/87/e1/4fa84e5a49738766fc7ef73cb4cdce161bf6e6c3329ddcf75d5cad055a8e/collective.monkeypatcher-1.1.4-py2-none-any.whl" }, { "comment_text": "", "digests": { "md5": "61af66e386603f526cb8266712620020", "sha256": "4a6f45967dc70fe135a3ddaf2020eaba1da86bb37086270eafcd609f42954e3c" }, "downloads": -1, "filename": "collective.monkeypatcher-1.1.4.tar.gz", "has_sig": false, "md5_digest": "61af66e386603f526cb8266712620020", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11969, "upload_time": "2018-04-08T18:45:00", "url": "https://files.pythonhosted.org/packages/16/30/1ab15249a563a39a2fa52c028853844dadb7ee7d9a4a6083b14fdead3545/collective.monkeypatcher-1.1.4.tar.gz" } ], "1.1.5": [ { "comment_text": "", "digests": { "md5": "63d9a7b3b626c197ebdb1aa05fa7ab72", "sha256": "f2b02b73d853d29b379001ef5e3cc9060c4a84d2ab6a02aa1c75c8e7c0871626" }, "downloads": -1, "filename": "collective.monkeypatcher-1.1.5-py2-none-any.whl", "has_sig": false, "md5_digest": "63d9a7b3b626c197ebdb1aa05fa7ab72", "packagetype": "bdist_wheel", "python_version": "py2", "requires_python": null, "size": 11371, "upload_time": "2018-06-18T14:45:42", "url": "https://files.pythonhosted.org/packages/43/4b/5b6f2e0debf819fa59c6ac7d92a1956847549b2eed016f97ca3adb41e232/collective.monkeypatcher-1.1.5-py2-none-any.whl" }, { "comment_text": "", "digests": { "md5": "6a4b61449ddd3302f717414cb809268b", "sha256": "d41871d3dad900967868db34883792c00bebd65646c685b7a3cff2317e388e01" }, "downloads": -1, "filename": "collective.monkeypatcher-1.1.5.tar.gz", "has_sig": false, "md5_digest": "6a4b61449ddd3302f717414cb809268b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12021, "upload_time": "2018-06-18T14:45:43", "url": "https://files.pythonhosted.org/packages/7d/76/17ced98ad2673c1646aa486ef4cd912ceab58841c4cad1da1a6bfcd2c592/collective.monkeypatcher-1.1.5.tar.gz" } ], "1.1.6": [ { "comment_text": "", "digests": { "md5": "c6000834c1b5de193b14cda4728baeea", "sha256": "24393789754be12df561fa823463526f3b1c6fce3e6d3cab429f12c74ba440b0" }, "downloads": -1, "filename": "collective.monkeypatcher-1.1.6-py2-none-any.whl", "has_sig": false, "md5_digest": "c6000834c1b5de193b14cda4728baeea", "packagetype": "bdist_wheel", "python_version": "py2", "requires_python": null, "size": 11430, "upload_time": "2018-10-31T11:28:25", "url": "https://files.pythonhosted.org/packages/2e/e5/585bde41428d205bc93d66af84a6d66ab03753df847748b80c86bf382422/collective.monkeypatcher-1.1.6-py2-none-any.whl" }, { "comment_text": "", "digests": { "md5": "c2319da57b2f3634b11a9634500e146f", "sha256": "5a806aa76f00f9a7130fd9148dae54f823d3e9fe22a207ecd5d730827583b629" }, "downloads": -1, "filename": "collective.monkeypatcher-1.1.6.tar.gz", "has_sig": false, "md5_digest": "c2319da57b2f3634b11a9634500e146f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10685, "upload_time": "2018-10-31T11:28:27", "url": "https://files.pythonhosted.org/packages/39/11/5bf6012b3c4c2ad79e4c736fe756af4cb17ba9627827d87728a250573247/collective.monkeypatcher-1.1.6.tar.gz" } ], "1.2": [ { "comment_text": "", "digests": { "md5": "811abc105b6f57299234e35d0c099513", "sha256": "498d556ed91948c27947d5c2d5ff91ad73439d007c7a1f97c207648d4a091139" }, "downloads": -1, "filename": "collective.monkeypatcher-1.2-py2-none-any.whl", "has_sig": false, "md5_digest": "811abc105b6f57299234e35d0c099513", "packagetype": "bdist_wheel", "python_version": "py2", "requires_python": null, "size": 12130, "upload_time": "2018-12-11T02:58:52", "url": "https://files.pythonhosted.org/packages/42/42/2a4c5c67e488a8eeb2f7b07ea80f104a4dc5b5cfe5d0cbced1106da3f87b/collective.monkeypatcher-1.2-py2-none-any.whl" }, { "comment_text": "", "digests": { "md5": "b9568eff55be23725d5b1bdc31329237", "sha256": "903ec9076adc66315205b8f5600748c4b07a56157d831c7f4bba725867b773aa" }, "downloads": -1, "filename": "collective.monkeypatcher-1.2.tar.gz", "has_sig": false, "md5_digest": "b9568eff55be23725d5b1bdc31329237", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11097, "upload_time": "2018-12-11T02:58:54", "url": "https://files.pythonhosted.org/packages/7c/b6/824c6a97ad8e7736577f55bb5b2923bbfe06a195cf485529530a26382513/collective.monkeypatcher-1.2.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "811abc105b6f57299234e35d0c099513", "sha256": "498d556ed91948c27947d5c2d5ff91ad73439d007c7a1f97c207648d4a091139" }, "downloads": -1, "filename": "collective.monkeypatcher-1.2-py2-none-any.whl", "has_sig": false, "md5_digest": "811abc105b6f57299234e35d0c099513", "packagetype": "bdist_wheel", "python_version": "py2", "requires_python": null, "size": 12130, "upload_time": "2018-12-11T02:58:52", "url": "https://files.pythonhosted.org/packages/42/42/2a4c5c67e488a8eeb2f7b07ea80f104a4dc5b5cfe5d0cbced1106da3f87b/collective.monkeypatcher-1.2-py2-none-any.whl" }, { "comment_text": "", "digests": { "md5": "b9568eff55be23725d5b1bdc31329237", "sha256": "903ec9076adc66315205b8f5600748c4b07a56157d831c7f4bba725867b773aa" }, "downloads": -1, "filename": "collective.monkeypatcher-1.2.tar.gz", "has_sig": false, "md5_digest": "b9568eff55be23725d5b1bdc31329237", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11097, "upload_time": "2018-12-11T02:58:54", "url": "https://files.pythonhosted.org/packages/7c/b6/824c6a97ad8e7736577f55bb5b2923bbfe06a195cf485529530a26382513/collective.monkeypatcher-1.2.tar.gz" } ] }