{ "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.search`` provides searching functionality for the Horae\nresource planning system by implementing a ajax driven full text search\nand a pluggable advanced search form. Additionally it implements a\nrestricted special ``Query`` implementation based on the one provided\nby `hurry.query `_ which only\nreturns results the user is allowed to see.\n\nUsage\n=====\n\nThere are several ways to extend and adjust the behaviour of the search\nforms and results by registering special adapters. The following possibilities\nare available for any views sub-classing from ``horae.search.search.SearchMixin``.\n\nExtending the advanced search form\n----------------------------------\n\nThe advanced search form may be extended by registering a named multi adapter\nimplementing ``horae.search.interfaces.IAdvancedSearchFieldProvider``\nand adapting the ``context`` and ``request``. If for example one would\nlike to add a new ``TextLine`` field searching in a custom catalog the\nimplementation would look something like this::\n\n import grok\n \n from zope import interface\n from zope import schema\n from zope.publisher.interfaces.browser import IBrowserRequest\n \n from hurry import query\n \n from horae.search import interfaces\n \n class SampleAdvancedSearchFieldProvider(grok.MultiAdapter):\n grok.adapts(interface.Interface, IBrowserRequest)\n grok.implements(interfaces.IAdvancedSearchFieldProvider)\n grok.name('sampleadvancedfieldprovider')\n \n def __init__(self, context, request):\n self.context = context\n self.request = request\n \n def fields(self):\n \"\"\" Returns a list of fields to be added to the form\n \"\"\"\n return [\n schema.TextLine(\n __name__ = 'sample_text_line',\n title = u'Sample text line'\n )\n ]\n \n def query(self, **data):\n \"\"\" Returns a list of queries\n \"\"\"\n queries = []\n if 'sample_text_line' in data:\n queries.append(query.Text(('samplecatalog', 'text'),\n data['sample_text_line']))\n return queries\n\nAdjusting default sorting\n-------------------------\n\nBy default the search results are sorted by a special integer index in the catalog.\nThis integer may be adjusted by registering a named adapter implementing\n``horae.search.interfaces.ISortingProvider`` and adapting the object the sorting\nshould be changed for. If for example one would like to move every ticket having\na special property set to the bottom of the search results the implementation\nwould look like this::\n\n from horae.ticketing.interfaces import ITicket\n \n class SampleSortingProvider(grok.Adapter):\n grok.context(ITicket)\n grok.implements(interfaces.ISortingProvider)\n grok.name('samplesortingprovider')\n \n def add(self):\n \"\"\" Returns an integer to be added to the sorting\n \"\"\"\n return 0\n \n def adjust(self, sorting):\n \"\"\" Adjusts the sorting after all providers sorting\n where added and returns the adjusted sorting\n \"\"\"\n if (self.context.get_property('my_special_property', None) is not None):\n return 0\n return sorting\n\nChanging default sorting\n------------------------\n\nAs mentioned above the default sorting of the search results is a special integer index\nin the catalog. This may be changed by registering an adapter implementing\n``horae.search.interfaces.IDefaultSortingProvider`` and adapting either the\nsearch view or the search view and the desired context. An example implementation\nchanging the default sorting of the advanced search results would look like this::\n\n from horae.search import search\n \n class SampleDefaultSortingProvider(grok.Adapter):\n grok.context(search.AdvancedSearch)\n grok.implements(interfaces.IDefaultSortingProvider)\n \n def sort_field(self):\n \"\"\" The index used to sort\n \"\"\"\n return ('samplecatalog', 'sorting')\n \n def reverse(self):\n \"\"\" Whether to reverse the sort order\n \"\"\"\n return False\n\nAdding columns\n--------------\n\nAdding new columns to the results table is possible by registering a named adapter\nimplementing ``horae.search.interfaces.IColumnProvider`` adapting the desired ``context``.\nThe following is an example implementation found in ``horae.search.search`` providing\na column showing whether an object has been completed or not::\n\n class CompleteColumnProvider(grok.Adapter):\n \"\"\" Column provider adding the complete column\n \"\"\"\n grok.implements(interfaces.IColumnProvider)\n grok.context(interface.Interface)\n grok.name('horae.search.column.complete')\n \n name = 'complete'\n title = _(u'Completed')\n sortable = None\n insert_after = '*'\n \n def __init__(self, context):\n self.context = context\n \n def filterable(self):\n \"\"\" Returns a vocabulary for filtering the column or\n None if no filtering is available\n \"\"\"\n return vocabulary.SimpleVocabulary([\n vocabulary.SimpleTerm(0, 'no', _p(u'No')),\n vocabulary.SimpleTerm(1, 'yes', _p(u'Yes'))\n ])\n \n def factory(self, object, request):\n \"\"\" Returns the value to be displayed for the given object\n \"\"\"\n return (IComplete(object, lambda: False)() and _p(u'Yes') or _p(u'No'))\n \n def cache_key(self, key, *args, **kwargs):\n \"\"\" Modifies the cache key if needed and returns it\n \"\"\"\n return key + parents_modification_cache_key(self.context)\n\nAdding row CSS class\n--------------------\n\nLast but not least one may add custom CSS classes to the rows by registering\na named adapter implementing ``horae.search.interfaces.IRowClassProvider``\nadapting the desired ``context``. An example implementation adding a CSS class\n``special`` if a ticket has a special property set would look like this::\n\n class SampleRowClassProvider(grok.Adapter):\n grok.context(ITicket)\n grok.implements(interfaces.IRowClassProvider)\n \n def classes(self):\n \"\"\" Returns a list of CSS classes to be set on the row\n \"\"\"\n if (self.context.get_property('my_special_property', None) is not None):\n return ['special']\n return []\n\nDependencies\n============\n\nHorae\n-----\n\n* `horae.auth `_\n* `horae.autocomplete `_\n* `horae.cache `_\n* `horae.core `_\n* `horae.layout `_\n* `horae.lifecycle `_\n* `horae.properties `_\n* `horae.ticketing `_\n\nThird party\n-----------\n\n* `grok `_\n* `zc.catalog `_\n* `hurry.query `_\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.search", "package_url": "https://pypi.org/project/horae.search/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/horae.search/", "project_urls": { "Download": "UNKNOWN", "Homepage": "UNKNOWN" }, "release_url": "https://pypi.org/project/horae.search/1.0a1/", "requires_dist": null, "requires_python": null, "summary": "Provides searching functionality for the Horae resource planning system", "version": "1.0a1" }, "last_serial": 793000, "releases": { "1.0a1": [ { "comment_text": "", "digests": { "md5": "c65acf1ef80a51381dfeb180f0c49d19", "sha256": "7c7fc21892b8a7a5eabfee04f48092f53b1a621c2162307ec9bb12d0c765874c" }, "downloads": -1, "filename": "horae.search-1.0a1.tar.gz", "has_sig": false, "md5_digest": "c65acf1ef80a51381dfeb180f0c49d19", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 18274, "upload_time": "2012-01-16T12:04:08", "url": "https://files.pythonhosted.org/packages/a8/28/f13cd9b1d16d88c7b4a33c52b215abe15bab3b2a116bb8d792508c824611/horae.search-1.0a1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "c65acf1ef80a51381dfeb180f0c49d19", "sha256": "7c7fc21892b8a7a5eabfee04f48092f53b1a621c2162307ec9bb12d0c765874c" }, "downloads": -1, "filename": "horae.search-1.0a1.tar.gz", "has_sig": false, "md5_digest": "c65acf1ef80a51381dfeb180f0c49d19", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 18274, "upload_time": "2012-01-16T12:04:08", "url": "https://files.pythonhosted.org/packages/a8/28/f13cd9b1d16d88c7b4a33c52b215abe15bab3b2a116bb8d792508c824611/horae.search-1.0a1.tar.gz" } ] }