Skip to content

Commit

Permalink
Add a test and update CHANGES for last change.
Browse files Browse the repository at this point in the history
  • Loading branch information
thefunny42 committed Apr 30, 2012
1 parent f7d1381 commit 199cc8a
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 0 deletions.
5 changes: 5 additions & 0 deletions CHANGES.txt
Expand Up @@ -4,6 +4,11 @@ Changelog
1.5 (unreleased)
----------------

- Add a directive ``layout`` to select a different type of layout. A layout
type is defined on a ``Layout`` component with the help of the
``grokcore.component.provides`` directive. It defaults to ``ILayout``
for compatibility.

- Change how the static resources are associated to a ``Layout``,
using the new name ``__static_name__`` set by the template grokker.

Expand Down
64 changes: 64 additions & 0 deletions src/grokcore/layout/tests/layout/selectlayout.py
@@ -0,0 +1,64 @@
"""
>>> one = One()
>>> from zope.publisher.browser import TestRequest
>>> from zope.component import getMultiAdapter
>>> request = TestRequest()
We test that we can retrieve the default layout for the page that
doesn't select any specific layout::
>>> view = getMultiAdapter((one, request), name="viewone")
>>> print view()
Layout One
We test that we can retrieve the default layout for the page that
select a specific layout::
>>> view = getMultiAdapter((one, request), name="viewtwo")
>>> print view()
Layout Two
"""
import grokcore.view as grok
from zope.interface import Interface
from grokcore.layout import Layout, Page, ILayout, layout


class One(grok.Context):
pass


class LayoutOne(Layout):
grok.context(One)

def render(self):
return "Layout One"


class ILayoutTwo(ILayout):
pass


class LayoutTwo(Layout):
grok.context(One)
grok.provides(ILayoutTwo)

def render(self):
return "Layout Two"


class ViewOne(Page):
grok.context(Interface)

def render(self):
return "MyView on regular layout"


class ViewTwo(Page):
grok.context(Interface)
layout(ILayoutTwo)

def render(self):
return "MyView on layout two"

0 comments on commit 199cc8a

Please sign in to comment.