{ "info": { "author": "Simon Kaeser", "author_email": "skaeser@gmail.com", "bugtrack_url": null, "classifiers": [ "Programming Language :: Python", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": "Introduction\n============\n\nThe ``horae.core`` package provides several core functionality used by the\n``horae.*`` packages which there are:\n\n* Formatters for:\n \n * Prices\n * Sizes\n * Dates and times\n * Hours\n \n* Global configuration defining:\n \n * Title and description of the application\n * Work days\n * The currency\n \n* Generic interfaces for objects having a textual or integer ID\n* Utility managing integer IDs\n* Utility creating textual IDs\n* Base implementation of a container holding objects having a textual\n or integer ID\n\nUsage\n=====\n\nFormatters\n----------\n\nPrices\n''''''\n\nThe price formatter formats the given value using the current locale and adds\nthe configured currency. The formatter is registered as an adapter implementing\n``horae.core.interfaces.ICurrencyFormatter`` and adapting any ``context`` and\nthe ``request``. The following example shows the usage of the formatter in a\nview::\n\n import grok\n from zope.component import getMultiAdapter\n \n from horae.core import interfaces\n \n class SampleView(grok.View):\n \n def currency_formatted_price(self):\n formatter = getMultiAdapter((self.context, self.request),\n interface=interfaces.ICurrencyFormatter)\n return formatter.format(1050.25)\n\nSizes\n'''''\n\nThe size formatter formats the given value (in bytes) as a number appending the\nappropriate unit (B, KB, MB, GB). The formatter is registered as an adapter\nimplementing ``horae.core.interfaces.ISizeFormatter`` and adapting the ``request``.\nThe following example shows the usage of the formatter in a view::\n\n class SampleView(grok.View):\n \n def size_formatted_price(self):\n return interfaces.ISizeFormatter(self.request).format(2048)\n\nDates and times\n'''''''''''''''\n\nThe date and time formatters are simple functions part of the ``horae.core.utils``\nmodule. There are two functions available:\n\n``formatDateTime(value, request, format=('dateTime', 'short'), html=True)``\n Formats the datetime ``value`` using the locale provided by the ``request``\n and the ``format`` provided. HTML output may be disabled by the ``html``\n argument.\n``formatDateTimeRange(start, end, request, format=('dateTime', 'short'), html=True)``\n Formats the datetime range (``start``, ``end``) using the locale provided\n by the ``request`` and the ``format`` provided. HTML output may be disabled\n by the ``html`` argument.\n\nHours\n'''''\n\nAs with the date and time formatters the hours formatter is a simple function of the\n``horae.core.utils`` module:\n\n``formatHours(value, request)``\n Formats the ``value`` as a decimal using the locale provided by the ``request``.\n\nIDs and base container implementation\n-------------------------------------\n\n``horae.core`` defines two interfaces for objects having an ID:\n\n``horae.core.interfaces.ITextId``\n An object having a text ID\n``horae.core.interfaces.IIntId``\n An object having an integer ID\n\nText IDs may be generated by the text ID manager which is a global utility implementing\n``horae.core.interfaces.ITextIdManager``. The utility has two methods:\n\n``normalize(name)``\n Returns a normalized string usable in URLs based on the ``name`` provided\n``idFromName(container, name)``\n Returns a valid ID for a new object to be added to the ``container`` from the ``name``\n provided\n\nInteger IDs are managed by the int ID manager which is a local utility implementing\n``horae.core.interfaces.IIntIdManager``. The utility provides a method to get the next\nID for a given key:\n\n``nextId(self, key)``\n Returns the next ID for the given ``key``\n\nContainer\n'''''''''\n\nThe base container implementation resides in the ``horae.core.container`` module and\nconsists of a ``Container`` class implementing ``horae.core.interfaces.IContainer``.\nThe container is mainly there to simplify the process of adding new objects implementing\none of the aforementioned ID interfaces. The ``add_object(obj)`` method checks if the\ngiven object has an attribute named ``id`` and whether it is ``None``. If no ID is available\none is generated. If the object implements ``horae.core.interfaces.ITextId`` the ID is\ngenerated by using the text ID manager otherwise by the int ID manager. A simple usage\nwould look like this::\n\n import grok\n \n from horae.core import interfaces, container\n \n class SampleContainer(container):\n \n def id_key(self):\n return 'sample_key'\n \n class SampleIntIdContent(grok.Model):\n grok.implements(interfaces.IIntId)\n \n class SampleTextIdContent(grok.Model):\n grok.implements(interfaces.ITextId)\n\nAn example usage of the above sample classes would look like this::\n\n >>> container = SampleContainer()\n >>> intcontent1 = SampleIntIdContent()\n >>> container.add_object(intcontent1)\n 1\n >>> intcontent1.id\n 1\n >>> intcontent2 = SampleIntIdContent()\n >>> container.add_object(intcontent2)\n 2\n >>> intcontent2.id\n 2\n >>> textcontent1 = SampleTextContent()\n >>> textcontent1.name = u'Test name of the content'\n >>> container.add_object(textcontent1)\n 'test_name_of_the_content'\n >>> textcontent1.id\n 'test_name_of_the_content'\n >>> textcontent2 = SampleTextContent()\n >>> textcontent2.name = u'Test name of the content'\n >>> container.add_object(textcontent2)\n 'test_name_of_the_content-2'\n >>> textcontent2.id\n 'test_name_of_the_content-2'\n\nDependencies\n============\n\nHorae\n-----\n\n* `horae.cache `_\n\nThird party\n-----------\n\n* `grok `_\n* `zope.app.locales `_\n* `z3c.taskqueue `_\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.core", "package_url": "https://pypi.org/project/horae.core/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/horae.core/", "project_urls": { "Download": "UNKNOWN", "Homepage": "UNKNOWN" }, "release_url": "https://pypi.org/project/horae.core/1.0a1/", "requires_dist": null, "requires_python": null, "summary": "Basic functionality for Horae", "version": "1.0a1" }, "last_serial": 792988, "releases": { "1.0a1": [ { "comment_text": "", "digests": { "md5": "8ed3c28cb27f9fc9d624c73f418e7a5c", "sha256": "1f61013914110b9546b32a41d892233b2ef7f442f60de26976d557c0a1265299" }, "downloads": -1, "filename": "horae.core-1.0a1.tar.gz", "has_sig": false, "md5_digest": "8ed3c28cb27f9fc9d624c73f418e7a5c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11777, "upload_time": "2012-01-16T12:02:52", "url": "https://files.pythonhosted.org/packages/5e/c8/92d05d584727eb84fc5c98ea92753006db39893ce68db4dbf70fb2cd33a1/horae.core-1.0a1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "8ed3c28cb27f9fc9d624c73f418e7a5c", "sha256": "1f61013914110b9546b32a41d892233b2ef7f442f60de26976d557c0a1265299" }, "downloads": -1, "filename": "horae.core-1.0a1.tar.gz", "has_sig": false, "md5_digest": "8ed3c28cb27f9fc9d624c73f418e7a5c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11777, "upload_time": "2012-01-16T12:02:52", "url": "https://files.pythonhosted.org/packages/5e/c8/92d05d584727eb84fc5c98ea92753006db39893ce68db4dbf70fb2cd33a1/horae.core-1.0a1.tar.gz" } ] }