{ "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.layout`` package provides the global layout for the Horae resource\nplanning system by defining base classes for views, forms (add, edit, delete and\ndisplay) and viewlets. Additionally the following features are provided:\n\n* Registration of several viewlet managers\n* Integration of `megrok.navigation `_\n* Helper view to create tables\n* Generic views for listing, adding, editing and deleting objects in a container\n* Possibility to register `fanstatic `_ resources\n through named adapters\n* Registration of the `horae.datetime `_\n widgets\n* Registration of rich text widgets using `megrok.form `_\n\nUsage\n=====\n\nViews\n-----\n\nThe aforementioned base classes for views, forms and viewlets are defined in\n``horae.layout.layout``. All the views defined there provide the functionality\nto be called with two special parameters provided through GET or POST:\n\n``plain``\n If this parameter is set to any truth value only the views result\n is rendered without the whole layout put around.\n``selector``\n If this parameter is set to any CSS selector only the contents of the element\n matching the selector is returned.\n\nThose base classes are also responsible for including the `fanstatic\n`_ resources provided by the named adapters\nimplementing ``horae.layout.interfaces.IResourceProvider``.\n\nAdd forms\n'''''''''\n\nCreating an add form using ``horae.layout`` is done by sub-classing from the provided\nbase class ``horae.layout.layout.AddForm`` and implementing the required methods::\n\n import grok\n \n from horae.layout import layout\n from some.module.interfaces import ISampleContent, ISampleContainer\n from some.module.content import SampleContent\n \n class AddSampleContent(layout.AddForm):\n grok.context(ISampleContainer)\n form_fields = grok.AutoFields(ISampleContent)\n \n def create(self, **data):\n return SampleContent()\n \n def add(self, obj):\n self.context[obj]\n\nThis will render a form having a ``Add`` and ``Cancel`` button.\n\nEdit forms\n''''''''''\n\nEdit forms work pretty much the same as add forms. The only difference is the class to be\nsub-classed and that there are no methods required to be implemented::\n\n class EditSampleContent(layout.EditForm):\n grok.context(ISampleContent)\n form_fields = grok.AutoFields(ISampleContent)\n\nThis will render a form having a ``Save changes`` and ``Cancel`` button.\n\nDisplay forms\n'''''''''''''\n\nLike edit forms display forms require no implementation at all::\n\n class DisplaySampleContent(layout.DisplayForm):\n grok.context(ISampleContent)\n form_fields = grok.AutoFields(ISampleContent)\n\nDelete forms\n''''''''''''\n\nDelete forms provide a confirmation view before actually deleting an object and are implemented\nby sub-classing from ``horae.layout.layout.DeleteForm``::\n\n class DeleteSampleContent(layout.DeleteForm):\n grok.context(ISampleContent)\n \n def item_title(self):\n return self.context.title\n\nView extenders\n''''''''''''''\n\nAdditionally the views sub-classing from those base classes may be extended by other\npackages using so called view extenders, which are named adapters implementing\n``horae.layout.interfaces.IViewExtender`` and adapting the view itself. If for example\none would like to add an additional field to the aforementioned add form without\ntouching the form itself::\n\n from zope import schema\n from horae.layout import interfaces\n \n class AddSampleContentExtender(grok.Adapter):\n grok.context(AddSampleContent)\n grok.implements(interfaces.IViewExtender)\n grok.name('addsamplecontentextender')\n \n def pre_update(self):\n \"\"\" Called before the views update is called\n \"\"\"\n self.context.form_fields = self.context.form_fields + \\\n grok.Fields(additional_field=schema.TextLine(\n title=u'Additional field'\n ))\n \n def pre_setUpWidgets(self, ignore_request=False):\n \"\"\" Called before the forms setUpWidgets is called\n \"\"\"\n # set custom widgets for fields using this method\n \n def post_update(self):\n \"\"\" Called after the views update is called\n \"\"\"\n # set default values for fields using this method\n \n def apply(self, obj, **data):\n \"\"\" Called when applying changes to an object\n \"\"\"\n obj.additional_field = data.get('additional_field', None)\n \n def validate(self, action, data):\n \"\"\" Called when validating a form\n \"\"\"\n # do custom validation using this method\n\nViewlet managers\n----------------\n\nThe following viewlet managers are registered in ``horae.layout.viewlets``:\n\n``TopManager``\n Viewlet manager rendered on top\n``HeaderLeftManager``\n Viewlet manager rendered on the left in the header\n``HeaderRightManager``\n Viewlet manager rendered on the right in the header\n``ContentBeforeManager``\n Viewlet manager rendered before the content\n``ContentAfterManager``\n Viewlet manager rendered after the content\n``SidebarManager``\n Viewlet manager rendered in the sidebar\n``FooterManager``\n Viewlet manager rendered in the footer\n\nNavigation\n----------\n\n``horae.layout`` registers several ``Menu``\\ s using the `megrok.navigation\n`_ package. Those are defined\nin ``horae.layout.navigation``:\n\n``MainNavigation`` (``horae.layout.interfaces.interfaces.IMainNavigation``)\n Main navigation holds global items and is rendered on the top left\n``GlobalManageMenu`` (``horae.layout.interfaces.interfaces.IGlobalManageMenu``)\n Global manage menu part of the main navigation\n``EditNavigation`` (``horae.layout.interfaces.interfaces.IEditNavigation``)\n Edit navigation holds sub menus and is rendered on the top right\n``ContextualManageMenu`` (``horae.layout.interfaces.interfaces.IContextualManageMenu``)\n Contextual manage menu part of the edit navigation\n``ViewsMenu`` (``horae.layout.interfaces.interfaces.IViewsMenu``)\n Views menu part of the edit navigation\n``ActionsMenu`` (``horae.layout.interfaces.interfaces.IActionsMenu``)\n Actions menu part of the edit navigation\n``AddMenu`` (``horae.layout.interfaces.interfaces.IAddMenu``)\n Add menu part of the edit navigation\n``MainActionsMenu`` (``horae.layout.interfaces.interfaces.IMainActionsMenu``)\n Main actions menu rendered in the content area\n\nTable helper view\n-----------------\n\nThe table helper view is implemented in ``horae.layout.table`` and registered as\na view named ``table``. The view handles sorting, filtering and pagination of\ntabular data. An example usage of the view may be found in\n``horae.layout.objects.ObjectOverview``.\n\nA simple usage may look like this::\n\n from zope.component import getMultiAdapter\n from zope.schema import vocabulary\n \n class SampleTableView(grok.View):\n \n def render_table(self):\n table = getMultiAdapter((self.context, self.request), name=u'table')\n table.page_size = 10\n table.columns = (\n ('col1', u'Column 1'),\n ('col2', u'Column 2')\n )\n table.sortable = {\n 'col1': 'col1',\n 'col2': 'col2'\n }\n table.filterable = {\n 'col1': vocabulary.SimpleVocabulary.fromValues([\n 'Group 1',\n 'Group 2',\n 'Group 3'\n ])\n }\n rows = [\n {'col1': 'Group 1', 'col2': 'Row 1'},\n {'col1': 'Group 1', 'col2': 'Row 2'},\n {'col1': 'Group 1', 'col2': 'Row 3'},\n {'col1': 'Group 2', 'col2': 'Row 4'},\n {'col1': 'Group 2', 'col2': 'Row 5'},\n {'col1': 'Group 2', 'col2': 'Row 6'},\n {'col1': 'Group 3', 'col2': 'Row 7'},\n {'col1': 'Group 3', 'col2': 'Row 8'},\n {'col1': 'Group 4', 'col2': 'Row 9'},\n ]\n filtering = table.filtering()\n if 'col1' in filtering:\n rows = [row for row in rows if row['col1'] in filtering['col1']]\n sort, reverse = table.sorting()\n if sort:\n rows = sorted(rows, key=lambda row: row[sort])\n if reverse:\n rows = reversed(rows)\n table.rows = rows\n return table()\n\nThis would result in a table of two columns and nine rows which is sortable by both\ncolumns and the first column is filterable.\n\nDependencies\n============\n\nHorae\n-----\n\n* `horae.core `_\n* `horae.datetime `_\n\nThird party\n-----------\n\n* `grok `_\n* `fanstatic `_\n* `zope.fanstatic `_\n* `zc.relation `_\n* `js.jquery `_\n* `js.jqueryui `_\n* `BeautifulSoup `_\n* `grokcore.chameleon `_\n* `megrok.navigation `_\n* `megrok.pagetemplate `_\n* `megrok.form `_\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.layout", "package_url": "https://pypi.org/project/horae.layout/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/horae.layout/", "project_urls": { "Download": "UNKNOWN", "Homepage": "UNKNOWN" }, "release_url": "https://pypi.org/project/horae.layout/1.0a1/", "requires_dist": null, "requires_python": null, "summary": "Provides the global layout for the Horae resource planning system", "version": "1.0a1" }, "last_serial": 792993, "releases": { "1.0a1": [ { "comment_text": "", "digests": { "md5": "28e368ea6e587df65012e1804afd9f04", "sha256": "f360cc678559207b04f149056f82ee7f71d8b4c4bbb6b1cc8fa482a65deb2a06" }, "downloads": -1, "filename": "horae.layout-1.0a1.tar.gz", "has_sig": false, "md5_digest": "28e368ea6e587df65012e1804afd9f04", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 57366, "upload_time": "2012-01-16T12:04:47", "url": "https://files.pythonhosted.org/packages/60/06/4c488f2bef100e5f6497c830d5afc616229f1db361cb9d1aabe16337765c/horae.layout-1.0a1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "28e368ea6e587df65012e1804afd9f04", "sha256": "f360cc678559207b04f149056f82ee7f71d8b4c4bbb6b1cc8fa482a65deb2a06" }, "downloads": -1, "filename": "horae.layout-1.0a1.tar.gz", "has_sig": false, "md5_digest": "28e368ea6e587df65012e1804afd9f04", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 57366, "upload_time": "2012-01-16T12:04:47", "url": "https://files.pythonhosted.org/packages/60/06/4c488f2bef100e5f6497c830d5afc616229f1db361cb9d1aabe16337765c/horae.layout-1.0a1.tar.gz" } ] }