{ "info": { "author": "Simon Kaeser", "author_email": "skaeser@gmail.com", "bugtrack_url": null, "classifiers": [ "Programming Language :: Python" ], "description": "Introduction\n============\n\n``horae.subscription`` provides generic subscription functionality for the\nHorae resource planning system.\n\nUsage\n=====\n\nObjects marked with the ``horae.subscription.interfaces.ISubscribeable``\ninterfaces receive the functionality of being subscribed to. Which means\na viewlet is displayed rendering all subscribers and a button to subscribe\nand unsubscribe if an adapter implementing\n``horae.subscription.interfaces.ISubscriber`` and adapting the request is available.\n\nThe subscribers of an ``horae.subscription.interfaces.ISubscribeable`` may be\nnotified by using the ``horae.subscription.interfaces.ISubscription`` adapter.\nFirst some basic implementations are required::\n\n import grok\n \n from horae.subscription import interfaces\n \n class Subscriber(object):\n grok.implements(interfaces.ISubscriber)\n \n def __init__(self, id, name, url=None):\n self.id = id\n self.name = name\n self.url = url\n \n def notify(self, message, subject):\n \"\"\" Sends the message to the subscriber\n \"\"\"\n print self.name + ': (' + subject + ') ' + subject\n \n def available(self, context):\n \"\"\" Whether this subscriber is currently available or not\n \"\"\"\n return True\n \n class Message(object):\n grok.implements(interfaces.IMessage)\n \n def __init__(self, subject, message):\n self._subject = subject\n self._message = message\n \n def subject(self):\n \"\"\" Returns the subject of the notification to be sent\n \"\"\"\n return self._subject\n \n def message(self, html=False):\n \"\"\" Returns the notification message to be sent\n \"\"\"\n return self._message\n \n class Subscribeable(grok.Model):\n grok.implements(interfaces.ISubscribeable)\n\nWith those implementations in place some subscriptions may be made and\na message may be sent to them.\n\nFirst we create a subscribeable object::\n\n >>> subscribeable = Subscribeable()\n\nNow we create two subscribers and subscribe them to the subscribeable::\n\n >>> subscriber1 = Subscriber('jsmith', 'John Smith')\n >>> subscriber2 = Subscriber('jdoe', 'John Doe')\n >>> subscription = interfaces.ISubscription(subscribeable)\n >>> subscription.subscribe(subscriber1)\n >>> subscription.subscribe(subscriber2)\n\nAnd send out a message::\n\n >>> message = Message('Test subject', 'Test message')\n >>> sent, failed = subscription.notify(message)\n John Smith: (Test subject) Test message\n John Doe: (Test subject) Test message\n >>> sent\n 2\n >>> failed\n 0\n\nUnsubscription is also done using the subscription adapter::\n\n >>> subscription.unsubscribe(subscriber2.id)\n >>> sent, failed = subscription.notify(message)\n John Smith: (Test subject) Test message\n >>> sent\n 1\n >>> failed\n 0\n\nDependencies\n============\n\nHorae\n-----\n\n* `horae.core `_\n* `horae.layout `_\n* `horae.ticketing `_\n\nThird party\n-----------\n\n* `grok `_\n\nChangelog\n=========\n\n1.0a1 (2012-01-16)\n------------------\n\n- Initial release", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "UNKNOWN", "keywords": "", "license": "GPL", "maintainer": null, "maintainer_email": null, "name": "horae.subscription", "package_url": "https://pypi.org/project/horae.subscription/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/horae.subscription/", "project_urls": { "Download": "UNKNOWN", "Homepage": "UNKNOWN" }, "release_url": "https://pypi.org/project/horae.subscription/1.0a1/", "requires_dist": null, "requires_python": null, "summary": "Provides functionality to subscribe to an object", "version": "1.0a1" }, "last_serial": 793002, "releases": { "1.0a1": [ { "comment_text": "", "digests": { "md5": "c2633a46ef4aa13566eeaad307ccfc84", "sha256": "2125958b05819b9cf532e8b36425cd7c08ac1cbab47bc7c77f5694a1707f6563" }, "downloads": -1, "filename": "horae.subscription-1.0a1.tar.gz", "has_sig": false, "md5_digest": "c2633a46ef4aa13566eeaad307ccfc84", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5616, "upload_time": "2012-01-16T12:01:32", "url": "https://files.pythonhosted.org/packages/a3/27/0243c7069a02db4e8d40f3990380f4cd4b2835cf106cdb4d69d0d2cf6aab/horae.subscription-1.0a1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "c2633a46ef4aa13566eeaad307ccfc84", "sha256": "2125958b05819b9cf532e8b36425cd7c08ac1cbab47bc7c77f5694a1707f6563" }, "downloads": -1, "filename": "horae.subscription-1.0a1.tar.gz", "has_sig": false, "md5_digest": "c2633a46ef4aa13566eeaad307ccfc84", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5616, "upload_time": "2012-01-16T12:01:32", "url": "https://files.pythonhosted.org/packages/a3/27/0243c7069a02db4e8d40f3990380f4cd4b2835cf106cdb4d69d0d2cf6aab/horae.subscription-1.0a1.tar.gz" } ] }