{ "info": { "author": "Grok Team", "author_email": "grok-dev@zope.org", "bugtrack_url": null, "classifiers": [ "Environment :: Web Environment", "Framework :: Zope3", "Intended Audience :: Developers", "License :: OSI Approved :: Zope Public License", "Programming Language :: Python", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: Implementation", "Programming Language :: Python :: Implementation :: CPython", "Programming Language :: Python :: Implementation :: PyPy" ], "description": "===============\ngrokcore.layout\n===============\n\nThe `grokcore.layout` package provides a simple way to write view\ncomponents which can be included into a defined layout. It turns\naround two main components : the Page and the Layout.\n\nLayout\n======\n\nThe layout is a component allowing you to design your site. Often,\nit's the common structure shared between all the pages. Technically,\nit is a class based on the view components interface, providing a\n'render' and 'update' method.\n\nLet's implement a simple Layout:\n\n >>> from grokcore.layout import Layout\n >>> from zope.interface import Interface\n >>> import grokcore.component as grok\n\n >>> class MyLayout(Layout):\n ... grok.name('mylayout')\n ... grok.context(Interface)\n ...\n ... def render(self):\n ... return u\"a simple layout\"\n\nWe grok our component:\n\n >>> grok_component('MyLayout', MyLayout)\n True\n\nWe check it has been correctly registered:\n\n >>> from grokcore.layout import ILayout\n >>> from zope.component import getMultiAdapter\n >>> from zope.publisher.browser import TestRequest\n\n >>> layout = getMultiAdapter((TestRequest(), Interface), ILayout)\n >>> isinstance(layout, MyLayout)\n True\n >>> print(layout.render())\n a simple layout\n\nNow let's see how to use this Layout in a specific context using a Page.\n\nPage\n====\n\nThe page is the specific code that you want to control. It is based on\nthe grokcore.View browser page implementation and therefore provides a\n``render`` and ``update`` method. The ``render`` method will simply\nreturn the specific HTML code generated by the template or the\n``render`` method code while ``__call__`` will lookup for a Layout\ncomponent and renders itself inside it.\n\nFirst, we'll create 2 models that will serve as exemples.\n\n >>> class Aurochs(grok.Context):\n ... description = u'Looks like a bull'\n\n >>> class Mammoth(grok.Context):\n ... description = u'Looks like an elephant'\n\nLet's create now a page that will display their description.\n\n >>> from grokcore.layout import Page\n >>> class AnimalDisplay(Page):\n ... grok.name('display')\n ... \t grok.context(Interface)\n ...\n ... def render(self):\n ... return self.context.description\n\nGrokking our Page will let us use it.\n\n >>> grok_component('AnimalDisplay', AnimalDisplay)\n True\n >>> wooly = Mammoth()\n >>> page = getMultiAdapter((wooly, TestRequest()), name='display')\n >>> print(page.content())\n Looks like an elephant\n >>> print(page())\n a simple layout\n\nAs we can see, the page is using the layout, on the __call__ to\nrender. Of course, this example Layout doesn't provide any interesting\nfeature. Let's create something more interesting, by using our page\nwith the help of the 'content' method:\n\n >>> class MammothLayout(Layout):\n ... grok.context(Mammoth)\n ...\n ...\t def render(self):\n ...\t return u'Header. Page: %s. Footer' % self.view.content()\n\n >>> grok_component('MammothLayout', MammothLayout)\n True\n >>> print(page())\n Header. Page: Looks like an elephant. Footer\n\nForms & Errorpages\n==================\n\nBaseclasses for Form views (FormPage, AddFormPage, EditFormPage and DisplayFormPage) and Error\nviews (NotFoundPage, ExceptionPage, UnauthorizedPage) are available which are\nall aware of Layout components like Page is.\n\n\nChangelog\n=========\n\n3.0.3 (2018-02-08)\n------------------\n\n- Bugfix: Exception pages did not report their contents as text/html, but used\n text/plain instead (from their `zope.errorview` baseclasses). Layouts and\n pages are about HTML however and the sensible default content type for those\n is `text/html`\n\n3.0.2 (2018-01-17)\n------------------\n\n- Replace the use of `grok.implements()` with the `@grok.implementer()`\n directive throughout.\n\n3.0.1 (2018-01-12)\n------------------\n\n- Rearrange tests such that Travis CI can pick up all functional tests too.\n\n3.0.0 (2018-01-10)\n------------------\n\n- Python 3 compatibility.\n\n1.6.1 (2016-02-15)\n------------------\n\n- Update tests.\n\n1.6 (2012-05-10)\n----------------\n\n- Moved the lookup for a specific layout to a helper method, so other\n layout aware components can use the same lookup.\n\n1.5.1 (2012-05-02)\n------------------\n\n- Do not require the [role] extra of grokcore.security anymore.\n\n1.5 (2012-05-02)\n----------------\n\n- Move the layout-aware form components to the grok package where the\n dependency with grokcore.formib can be mixed in.\n\n- Add a directive ``layout`` to select a different type of layout. A layout\n type is defined on a ``Layout`` component with the help of the\n ``grokcore.component.provides`` directive. It defaults to ``ILayout``\n for compatibility.\n\n- Change how the static resources are associated to a ``Layout``,\n using the new name ``__static_name__`` set by the template grokker.\n\n1.4 (2011-07-13)\n----------------\n\n- Rename megrok.layout to grokcore.layout. ``application_url`` and ``flash``\n utilities have been removed, \\*Form components have been renamed to\n \\*FormPage.\n\n- Added ExceptionPage, NotFoundPage and UnauthorizedPage layout-aware\n components.\n\n- Fixed default template for grokcore.layout.Form component.\n\n1.3 (2011-01-12)\n----------------\n\n- Compatibility with grokcore.view 2.3.\n\n1.2.0 (2010-12-16)\n------------------\n\n- Update to use the new TemplateGrokker from grokcore.view.\n\n1.1.0 (2010-03-03)\n------------------\n\n- ``z3c.flashmessage`` has been dropped in favor of\n ``grokcore.message``. This new package takes in charge the\n registration of the utilities and retains the existing API. The\n back-compatibility is assured.\n\n1.0.2 (2010-02-26)\n------------------\n\n- The existence test for the `application_url` site-lookup was\n wrongly using a \"if not\" statement. In a case of a container, the object\n is evaluated to False if it's empty. We now use a proper \"if .. is\n None\". [trollfot]\n\n1.0.1 (2010-02-25)\n------------------\n\n- Forms now inherit from `UtilityView` and therefore get the\n `application_url` and `flash` methods. Tests have been added to\n garanty the behavior. [trollfot]\n\n1.0 (2010-02-25)\n----------------\n\n- The dependencies have been heavily cleaned up. All zope.app packages\n have been removed. We are now running with minimal dependencies and\n using the latest ZTK. This release will probably *not* run on\n `Grok 1.0`. You will need `Grok 1.1rc1` to be able to use\n it. [trollfot]\n\n- Added a component called UtilityView that provides two useful\n methods : application_url, flash. These methods are almost a copy of\n what can be found in the `Grok` package. The application_url is\n using a simple getSite hook to get the root of the application. This\n might be irrelevant for some applications and can be overriden.\n [trollfot]\n\n- Added a module called 'messages' that contains the flash messages\n utilities. This module is *NOT* grokked and must be grokked\n manually. This prevents conflicts with grokui.admin's own\n definitions of the very same components. It also allows you to\n override the `flash` method to use something else than\n z3c.flashmessage and then not be bothered by useless utilities. The\n flash messages utilities can be registered by including the\n ``messages.zcml`` file in your own project or package ZCML file.\n [trollfot]\n\n0.9 (2009-09-26)\n----------------\n\n- Add default templates to form which doesn't contain an html and body\n tag.\n [sylvain]\n\n- Add an AddForm, EditForm and DisplayForm, all aware of the layout\n component.\n [sylvain]\n\n0.8 (2009-09-17)\n----------------\n\n- Remove the CodePage, since CodeView have been removed from\n grokcore.view.\n [sylvain]\n\n0.7 (2009-09-15)\n----------------\n\n- Add a CodePage to be compatible with the last version of\n grokcore.view (higher than 1.9). This breaks compatibility with\n previous release. You need to change any Page using a render method\n to a CodePage.\n [sylvain]\n\n- The content property on a Page is no longer a property, but a method\n as it's hidding exceptions. You might need to update your code to\n reflect that change as well.\n [sylvain]\n\n- Fix MANIFEST.in.\n [sylvain]\n\n0.6 (2009-09-14)\n----------------\n\n- switch the arguments order in calling the layout\n [cklinger, sylvain]\n\n- add the CHANGES.txt\n [cklinger]\n\n0.5 (2009-07-24)\n----------------\n\n- remove the grok dependency\n [cklinger trollfot]", "description_content_type": null, "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://grok.zope.org", "keywords": "grok layout zope3 pagelet theming", "license": "ZPL", "maintainer": "", "maintainer_email": "", "name": "grokcore.layout", "package_url": "https://pypi.org/project/grokcore.layout/", "platform": "", "project_url": "https://pypi.org/project/grokcore.layout/", "project_urls": { "Homepage": "http://grok.zope.org" }, "release_url": "https://pypi.org/project/grokcore.layout/3.0.3/", "requires_dist": null, "requires_python": "", "summary": "A layout component package for zope3 and Grok.", "version": "3.0.3" }, "last_serial": 3563527, "releases": { "1.4": [ { "comment_text": "", "digests": { "md5": "df47daead06af5f0d3a92b1cfec0aa4a", "sha256": "b297ec96ed20883bdaf360b442a91bc8c35037a282fbe528f35ec5058ab0a962" }, "downloads": -1, "filename": "grokcore.layout-1.4.tar.gz", "has_sig": false, "md5_digest": "df47daead06af5f0d3a92b1cfec0aa4a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 14412, "upload_time": "2011-07-13T20:24:42", "url": "https://files.pythonhosted.org/packages/c1/95/1f5248273ac9c3e24ec51c1fb34f02df8db1f53277fbba29ec8664911948/grokcore.layout-1.4.tar.gz" } ], "1.5": [ { "comment_text": "", "digests": { "md5": "cba1e8418afe222acc32d73be99fb794", "sha256": "17f26d0aa38bbcde2c3e8794b3dd550d3a13bc36f282375d1b23d3ab11e07f7c" }, "downloads": -1, "filename": "grokcore.layout-1.5.tar.gz", "has_sig": false, "md5_digest": "cba1e8418afe222acc32d73be99fb794", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 13535, "upload_time": "2012-05-02T09:44:57", "url": "https://files.pythonhosted.org/packages/e5/61/efd8e8e53b5389bdcac18fe0ada222804cc406985f1c98699c6723727a13/grokcore.layout-1.5.tar.gz" } ], "1.5.1": [ { "comment_text": "", "digests": { "md5": "3da825e1b6cb6420b4cf149ff818e747", "sha256": "0bf5aefa618ff099d3e0be44cd334cac7e6ec28ccc83087142932114c0bf307e" }, "downloads": -1, "filename": "grokcore.layout-1.5.1.tar.gz", "has_sig": false, "md5_digest": "3da825e1b6cb6420b4cf149ff818e747", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 13604, "upload_time": "2012-05-02T11:47:00", "url": "https://files.pythonhosted.org/packages/06/ca/6f727f1610c8ea214e6dcb9547eaa60a9867b32b90de2339289d668f912c/grokcore.layout-1.5.1.tar.gz" } ], "1.6": [ { "comment_text": "", "digests": { "md5": "bf57d8f61670d31eb1d6134eb907eb7b", "sha256": "c5dabaf45c000c03788535170911c87bfc04f98ef5cf90236342c39e70ef9bcb" }, "downloads": -1, "filename": "grokcore.layout-1.6.tar.gz", "has_sig": false, "md5_digest": "bf57d8f61670d31eb1d6134eb907eb7b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 13713, "upload_time": "2012-05-10T13:05:51", "url": "https://files.pythonhosted.org/packages/10/62/f26cea14f63e1a5fc7106bf346d8efb52bfc79865e5af549c7b72e58bc79/grokcore.layout-1.6.tar.gz" } ], "1.6.1": [ { "comment_text": "", "digests": { "md5": "b09541b2189b4ab703a6e3dfbe2b16c8", "sha256": "3fa6266e27e32adf616766acfb5eb5697658d0400c17003094afa5cb0f4d1f1a" }, "downloads": -1, "filename": "grokcore.layout-1.6.1.tar.gz", "has_sig": false, "md5_digest": "b09541b2189b4ab703a6e3dfbe2b16c8", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 17730, "upload_time": "2016-02-15T15:16:42", "url": "https://files.pythonhosted.org/packages/31/71/ca3df2d6b3d65718b457b9b7318c41a82a39441c421986c749952c6f33ae/grokcore.layout-1.6.1.tar.gz" } ], "3.0.0": [ { "comment_text": "", "digests": { "md5": "6f9a95fc7414078924624f15eded99ad", "sha256": "edbb343e86a3738b64fa76e76ed70c1daf07da14413fd28ec2656ded1fa8673a" }, "downloads": -1, "filename": "grokcore.layout-3.0.0.tar.gz", "has_sig": false, "md5_digest": "6f9a95fc7414078924624f15eded99ad", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 18051, "upload_time": "2018-01-10T15:18:06", "url": "https://files.pythonhosted.org/packages/25/3b/1d755f6fd7b7312670348ba9980504432486d53275568edd56eacb6db001/grokcore.layout-3.0.0.tar.gz" } ], "3.0.1": [ { "comment_text": "", "digests": { "md5": "5818478c7f3992fcae4d203d0acc75c9", "sha256": "487921a090478da74729efd468b3caab83d4ddd6a7f12479c897dce6efede28a" }, "downloads": -1, "filename": "grokcore.layout-3.0.1.tar.gz", "has_sig": false, "md5_digest": "5818478c7f3992fcae4d203d0acc75c9", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 18275, "upload_time": "2018-01-12T13:13:02", "url": "https://files.pythonhosted.org/packages/ba/7f/756a2026718d2b942df6fca237cadf2c3a3613ac68f7a583628d8fc83cb7/grokcore.layout-3.0.1.tar.gz" } ], "3.0.2": [ { "comment_text": "", "digests": { "md5": "cc3303dfd3bc85fb02c39695791ba2be", "sha256": "f55c307a41e7bbe71a64650e8f6d202cd7df2ec727f655253d0374e2c17a5231" }, "downloads": -1, "filename": "grokcore.layout-3.0.2.tar.gz", "has_sig": false, "md5_digest": "cc3303dfd3bc85fb02c39695791ba2be", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 18391, "upload_time": "2018-01-17T12:41:05", "url": "https://files.pythonhosted.org/packages/cb/da/c388d8655a59db44754f8c9d706954a2be1877689f6ab02014124ab056c2/grokcore.layout-3.0.2.tar.gz" } ], "3.0.3": [ { "comment_text": "", "digests": { "md5": "e837db20d79673c992c9003588ef2393", "sha256": "13e4440e9398135aed70ab1f7686f20cbfeddd75d907c751f843fab791e9c1b4" }, "downloads": -1, "filename": "grokcore.layout-3.0.3.tar.gz", "has_sig": false, "md5_digest": "e837db20d79673c992c9003588ef2393", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 19573, "upload_time": "2018-02-08T12:20:21", "url": "https://files.pythonhosted.org/packages/27/96/95e955b22d01be1ef60cede8fd0df293d99022a56d866d94ce9cb37faafb/grokcore.layout-3.0.3.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "e837db20d79673c992c9003588ef2393", "sha256": "13e4440e9398135aed70ab1f7686f20cbfeddd75d907c751f843fab791e9c1b4" }, "downloads": -1, "filename": "grokcore.layout-3.0.3.tar.gz", "has_sig": false, "md5_digest": "e837db20d79673c992c9003588ef2393", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 19573, "upload_time": "2018-02-08T12:20:21", "url": "https://files.pythonhosted.org/packages/27/96/95e955b22d01be1ef60cede8fd0df293d99022a56d866d94ce9cb37faafb/grokcore.layout-3.0.3.tar.gz" } ] }