{ "info": { "author": "Jan Mil\u00c3\u00adk", "author_email": "milikjan@fit.cvut.cz", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta" ], "description": "nmevent v0.3.2 - C#-like implementation of the Observer pattern\r\n\r\nThis is a Python module `nmevent`, simple C#-like implementation of\r\nthe Observer pattern (http://en.wikipedia.org/wiki/Observer_pattern).\r\nIt's main purpose and goal is to allow developers to use events\r\nwith C#-like syntax in their Python classes.\r\n\r\n=============\r\nUsage example\r\n=============\r\n\r\nThe most straightfoward way to use `nmevent` is this:\r\n\r\n>>> import nmevent\r\n>>> class ExampleClass(object):\r\n... def __init__(self):\r\n... self.event = nmevent.Event()\r\n... \r\n... def do_something(self):\r\n... self.event(self)\r\n...\r\n>>> def handler(sender, **keywords):\r\n... print \"event occured\"\r\n...\r\n>>> example = ExampleClass()\r\n>>> example.event += handler\r\n>>> example.do_something()\r\nevent occured\r\n\r\nIt should be noted, that event doesn't necessarily need to be an object\r\nattribute. `Event` instance is basically just a callable object that\r\nworks as a sort of \"dispatch demultiplexer\".\r\n\r\nThis usage, however, isn't very C#-like. In C#, events are declared in class\r\nscope and that's why the `Event` class also supports the descriptor\r\nprotocol (you can use the same way you use the built-in ``property`` object).\r\n\r\n>>> from nmevent import Event\r\n>>> class ExampleClass(object):\r\n... event = Event()\r\n...\r\n... def _do_something(self):\r\n... self.event()\r\n...\r\n>>> def handler(sender, **keywords):\r\n... pass\r\n...\r\n>>> example = ExampleClass()\r\n>>> example.event += handler\r\n\r\nPerhaps this looks even more straightfoward than instantiating `Event`\r\nin object's constructor, but there's actually lot more going on under hood this\r\ntime.\r\n\r\nFinally, there is the `Property` descriptor and the associated\r\n`nmproperty` function decorator, which work very much like the built-in\r\n``property`` object and decorator, except it can optionally call a callback\r\nfunction if the property's value changes after calling the setter function. It\r\ncan work in tandem with the `with_events` class decorator, which\r\ndecorates the class with property change events and connects them to the\r\ninstances of `Property` class. It also creates events for the built-in\r\n``property`` objects, but you have to raise the events yourself in the setter\r\nfunction or elsewhere.\r\n\r\n>>> @nmevent.with_events\r\n... class ExampleClass(object):\r\n... @nmevent.nmproperty\r\n... def x(self):\r\n... return self._x\r\n...\r\n... @x.setter\r\n... def x(self, value):\r\n... self._x = value\r\n...\r\n... @property\r\n... def y(self):\r\n... return self._y\r\n...\r\n... @y.setter\r\n... def y(self, value):\r\n... old_value, self._y = self._y, value\r\n... self.y_changed(old_value = old_value)\r\n... \r\n... def __init__(self):\r\n... self._x = None\r\n... self._y = None\r\n...\r\n>>> def handler(sender, **keywords):\r\n... print \"x changed\"\r\n...\r\n>>> example = ExampleClass()\r\n>>> example.x_changed += handler\r\n>>> example.x = 10 # handler gets called\r\nx changed\r\n\r\n=======\r\nLicense\r\n=======\r\n\r\nCopyright (c) 2010, Jan Mil\u00edk.\r\n\r\nThis program is free software: you can redistribute it and/or modify\r\nit under the terms of the GNU Lesser General Public License as published by\r\nthe Free Software Foundation, either version 3 of the License, or\r\n(at your option) any later version.\r\n\r\nThis program is distributed in the hope the it will be useful,\r\nbut WITHOUT ANY WARRANTY; without event the implied warranty of\r\nMERCHANTIBILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r\nGNU Lesser General Public License for more details.\r\n\r\nYou should have received a copy of the GNU Lesser General Public License\r\nalong with this program. If not, see .\r\n\r\n=======\r\nChanges\r\n=======\r\n\r\nv0.3.2\r\n Added fairly useful functionality to the `adapt` function: it\r\n can now connect to \"nested events\". See the functions's documentation\r\n for more information. It can also disconnect the handlers as well.\r\n\r\nv0.3.1\r\n Added docstring tests and fixed all the docstrings so that they\r\n would pass. As a result, another problem was found with the event\r\n binding. That problem was fixed by adding the `InstanceEvent.bind`\r\n method to be used mainly by the `Property` class when raising\r\n the \"changed\" events.\r\n\r\nv0.3\r\n Fixed a major bug, which caused an unbound event not to be actually\r\n bound when called with an object instance as the first argument.\r\n\r\n Added the `with_properties` class decorator, which automatically\r\n decorates a class with \"private\" attributes for each property and\r\n automatic getters and setters where either one of them is missing.\r\n\r\nv0.2.1\r\n Rewritten some unit tests and added new ones. Improved documentation\r\n a little bit.\r\n\r\nv0.2\r\n Rewritten most of the code. The `Event` class now works as a \r\n descriptor, which eliminated the need for a separate `EventSlot`\r\n class and simplified usage. Added `CallbackStore` to abstract\r\n the callback storage. \r\n\r\nv0.1.1\r\n No changes in source code. Improved documentation and unit tests.\r\n\r\nv0.1\r\n Initial release.", "description_content_type": null, "docs_url": "https://pythonhosted.org/nmevent/", "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://pypi.python.org/pypi/nmevent", "keywords": "library event observer pattern", "license": "Lesser General Public License v3", "maintainer": "", "maintainer_email": "", "name": "nmevent", "package_url": "https://pypi.org/project/nmevent/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/nmevent/", "project_urls": { "Download": "UNKNOWN", "Homepage": "http://pypi.python.org/pypi/nmevent" }, "release_url": "https://pypi.org/project/nmevent/0.3.2/", "requires_dist": null, "requires_python": null, "summary": "A simple C#-like implementation of the Observer design pattern.", "version": "0.3.2" }, "last_serial": 795461, "releases": { "0.1": [ { "comment_text": "", "digests": { "md5": "90fc248e0845191be5c5bdcfd8cce651", "sha256": "b4d64e66005415ff016f735a57d4d809bc46defa88bee8af3c2f1578e985d72e" }, "downloads": -1, "filename": "nmevent-0.1.tar.gz", "has_sig": false, "md5_digest": "90fc248e0845191be5c5bdcfd8cce651", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4551, "upload_time": "2010-08-02T17:55:43", "url": "https://files.pythonhosted.org/packages/dc/60/66df8e6901fb840957dfb4b9ef5540c459c74821278821a6d7231f141c6a/nmevent-0.1.tar.gz" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "4bb7b23540906ad96010651695e927a5", "sha256": "1c136e822c3ae7b2fd83447f1cfcb8807f35548bed17b7d35a5c6064843752f9" }, "downloads": -1, "filename": "nmevent-0.1.1.tar.gz", "has_sig": false, "md5_digest": "4bb7b23540906ad96010651695e927a5", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9499, "upload_time": "2010-08-03T18:46:58", "url": "https://files.pythonhosted.org/packages/49/d5/4d734c02db50664abf6d37d6a13f9f44564e8077a15557e5e09a141d66fc/nmevent-0.1.1.tar.gz" } ], "0.2": [ { "comment_text": "", "digests": { "md5": "a22546e625c15fd78d595f2eba2df1c5", "sha256": "51aec8177fba328a2dffa978f4024810ce189246cbec6d7f8ebe53b2949a7d75" }, "downloads": -1, "filename": "nmevent-0.2.tar.gz", "has_sig": false, "md5_digest": "a22546e625c15fd78d595f2eba2df1c5", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 70559, "upload_time": "2010-08-04T15:13:14", "url": "https://files.pythonhosted.org/packages/6b/fb/f97fb1a9fcb8e5ce871295b49eb42ab6c41dbcf44e1c3502e3cf16c26b55/nmevent-0.2.tar.gz" } ], "0.2.1": [ { "comment_text": "", "digests": { "md5": "8061c0ce7268dce0d6407821480c1131", "sha256": "62b1c5261306ceb4ba55f6ede943766ce1432d490a23a489349c6dcb421a04a5" }, "downloads": -1, "filename": "nmevent-0.2.1-py2.6.egg", "has_sig": false, "md5_digest": "8061c0ce7268dce0d6407821480c1131", "packagetype": "bdist_egg", "python_version": "2.6", "requires_python": null, "size": 15742, "upload_time": "2010-08-07T15:05:23", "url": "https://files.pythonhosted.org/packages/3d/74/f793c97958acbc6c706cd678b80ec05988077810c483af76c1870ba1cc4e/nmevent-0.2.1-py2.6.egg" }, { "comment_text": "", "digests": { "md5": "43c891faee4593dd6dbffd022798b434", "sha256": "abf63c4b4f3cc100ad7faa2c23ff9ba9272ffdd45866f3fcfab69af0c2e59ee4" }, "downloads": -1, "filename": "nmevent-0.2.1.tar.gz", "has_sig": false, "md5_digest": "43c891faee4593dd6dbffd022798b434", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 71848, "upload_time": "2010-08-07T14:44:37", "url": "https://files.pythonhosted.org/packages/ed/e8/8e3416c49d7ab5019d1221d6ed0eec586256f2ab8c1a1c0003a21cc98d10/nmevent-0.2.1.tar.gz" }, { "comment_text": "", "digests": { "md5": "c770c410894de144e7a392f7a464e14a", "sha256": "3b0d8e82cdc3625969fd2e34ffc725907b60716bb0d5d60464ca1951fd018a14" }, "downloads": -1, "filename": "nmevent-0.2.1.win32-py2.6.exe", "has_sig": false, "md5_digest": "c770c410894de144e7a392f7a464e14a", "packagetype": "bdist_wininst", "python_version": "2.6", "requires_python": null, "size": 209270, "upload_time": "2010-08-07T15:04:06", "url": "https://files.pythonhosted.org/packages/18/78/03a7578fe0bc741d4f18499c85d1b936491c928913294cee4ed15976beee/nmevent-0.2.1.win32-py2.6.exe" } ], "0.3": [ { "comment_text": "", "digests": { "md5": "74001620c530d733ffee712fca7926a9", "sha256": "b289a851f03ec055188a3dd316891af54ca143d8a323eade636e07bceb81e5b0" }, "downloads": -1, "filename": "nmevent-0.3-py2.6.egg", "has_sig": false, "md5_digest": "74001620c530d733ffee712fca7926a9", "packagetype": "bdist_egg", "python_version": "2.6", "requires_python": null, "size": 17305, "upload_time": "2010-11-06T22:12:45", "url": "https://files.pythonhosted.org/packages/05/d9/6da2e716c183a1057aa86b77b7e0c09bf64afda6298c4c96f8050ddfe2d4/nmevent-0.3-py2.6.egg" }, { "comment_text": "", "digests": { "md5": "c05fe9df1c03acaac948357f43b5ff1b", "sha256": "87b5e89e5cb22bda310956bd8809550e22ce1e8ed916512f2cba4fffb5c53d52" }, "downloads": -1, "filename": "nmevent-0.3.win32.exe", "has_sig": false, "md5_digest": "c05fe9df1c03acaac948357f43b5ff1b", "packagetype": "bdist_wininst", "python_version": "any", "requires_python": null, "size": 210347, "upload_time": "2010-11-06T22:14:03", "url": "https://files.pythonhosted.org/packages/e6/da/de20105584a399700c964950202b2fee453ec4f5cf46bf173e4a681d1124/nmevent-0.3.win32.exe" }, { "comment_text": "", "digests": { "md5": "57ffcfaf618d22aed7e908eaca0c46cc", "sha256": "8134172103a1d6f0bbfca05d66113591ebbbf2ec4155b321458570aefa3190f3" }, "downloads": -1, "filename": "nmevent-0.3.zip", "has_sig": false, "md5_digest": "57ffcfaf618d22aed7e908eaca0c46cc", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 80577, "upload_time": "2010-11-06T22:14:45", "url": "https://files.pythonhosted.org/packages/01/22/855076de237bc24fd0ccf846e297f3393fe43c883b8659af85a31cb790fc/nmevent-0.3.zip" } ], "0.3.1": [ { "comment_text": "", "digests": { "md5": "38f75e3d9f79e6712283a7481b623540", "sha256": "9feecf94b32c0733f5b65b45496795a7c1ebfdbfab2271832388c4e24eaea1a1" }, "downloads": -1, "filename": "nmevent-0.3.1-py2.6.egg", "has_sig": false, "md5_digest": "38f75e3d9f79e6712283a7481b623540", "packagetype": "bdist_egg", "python_version": "2.6", "requires_python": null, "size": 18444, "upload_time": "2010-11-07T01:43:44", "url": "https://files.pythonhosted.org/packages/e9/9d/8ed152d90d6b25fbd495158036ceecc924606338c72d9ae3ac695758af86/nmevent-0.3.1-py2.6.egg" }, { "comment_text": "", "digests": { "md5": "6744540860d63ab0acb0930fa075b0c0", "sha256": "83f84924cf6ef646a91f8b276c613f36ebd91ecc10006a564dcd73ec821a084e" }, "downloads": -1, "filename": "nmevent-0.3.1.tar.gz", "has_sig": false, "md5_digest": "6744540860d63ab0acb0930fa075b0c0", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 75034, "upload_time": "2010-11-07T01:43:43", "url": "https://files.pythonhosted.org/packages/4d/19/2e9062762035aa3f378739e0340bcef4868bc2497a01756646de2d1e814b/nmevent-0.3.1.tar.gz" } ], "0.3.2": [ { "comment_text": "", "digests": { "md5": "eaa2cc1eb35d089923608213c7280bfa", "sha256": "1e28aa54799b7390e130713a27d871de3d8edc60727ed87600efdc846713be70" }, "downloads": -1, "filename": "nmevent-0.3.2-py2.6.egg", "has_sig": false, "md5_digest": "eaa2cc1eb35d089923608213c7280bfa", "packagetype": "bdist_egg", "python_version": "2.6", "requires_python": null, "size": 21696, "upload_time": "2010-11-28T17:44:31", "url": "https://files.pythonhosted.org/packages/31/4d/9d2238b3b053a126a3f14adee7fe706bd19da713d74e26110e2fe3074268/nmevent-0.3.2-py2.6.egg" }, { "comment_text": "", "digests": { "md5": "ea77150ee47150558791a376c3019094", "sha256": "c8f58360ec4ab00d33423d13a253ef26adf43335455bfe43fbf0562cdb2a8621" }, "downloads": -1, "filename": "nmevent-0.3.2.tar.gz", "has_sig": false, "md5_digest": "ea77150ee47150558791a376c3019094", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 79114, "upload_time": "2010-11-28T17:44:31", "url": "https://files.pythonhosted.org/packages/6c/d8/b14d45b6d4d478fe69a0f3348eef7fe4dd81496b560185b8be13646e851f/nmevent-0.3.2.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "eaa2cc1eb35d089923608213c7280bfa", "sha256": "1e28aa54799b7390e130713a27d871de3d8edc60727ed87600efdc846713be70" }, "downloads": -1, "filename": "nmevent-0.3.2-py2.6.egg", "has_sig": false, "md5_digest": "eaa2cc1eb35d089923608213c7280bfa", "packagetype": "bdist_egg", "python_version": "2.6", "requires_python": null, "size": 21696, "upload_time": "2010-11-28T17:44:31", "url": "https://files.pythonhosted.org/packages/31/4d/9d2238b3b053a126a3f14adee7fe706bd19da713d74e26110e2fe3074268/nmevent-0.3.2-py2.6.egg" }, { "comment_text": "", "digests": { "md5": "ea77150ee47150558791a376c3019094", "sha256": "c8f58360ec4ab00d33423d13a253ef26adf43335455bfe43fbf0562cdb2a8621" }, "downloads": -1, "filename": "nmevent-0.3.2.tar.gz", "has_sig": false, "md5_digest": "ea77150ee47150558791a376c3019094", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 79114, "upload_time": "2010-11-28T17:44:31", "url": "https://files.pythonhosted.org/packages/6c/d8/b14d45b6d4d478fe69a0f3348eef7fe4dd81496b560185b8be13646e851f/nmevent-0.3.2.tar.gz" } ] }