Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
re-add tests that got accidentally removed
- Loading branch information
1 parent
4ec837a
commit 30dbb68
Showing
6 changed files
with
113 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
""" | ||
>>> from zope.component import getMultiAdapter | ||
>>> from zope.publisher.browser import TestRequest | ||
>>> view = getMultiAdapter((Exception(), TestRequest()), name='index') | ||
>>> import grokcore.layout | ||
>>> isinstance(view, grokcore.layout.ExceptionPage) | ||
True | ||
>>> print view.render() | ||
A system error occurred. | ||
>>> print view() | ||
<html> | ||
<body> | ||
<div class="layout">A system error occurred.</div> | ||
</body> | ||
</html> | ||
>>> from zope.security.interfaces import Unauthorized | ||
>>> class MockPrincipal(object): | ||
... id = 'mock principal' | ||
>>> request = TestRequest() | ||
>>> request.setPrincipal(MockPrincipal()) | ||
>>> errorpage = getMultiAdapter((Unauthorized(), request), name='index') | ||
>>> print errorpage() | ||
<html> | ||
<body> | ||
<div class="layout">Access to the requested resource is forbidden.</div> | ||
</body> | ||
</html> | ||
>>> from zope.publisher.interfaces import NotFound | ||
>>> request = TestRequest() | ||
>>> errorpage = getMultiAdapter( | ||
... (NotFound(None, request), request), name='index') | ||
>>> print errorpage() | ||
<html> | ||
<body> | ||
<div class="layout">The requested resource can not be found.</div> | ||
</body> | ||
</html> | ||
""" | ||
import grokcore.component as grok | ||
|
||
from grokcore.view import templatedir | ||
from grokcore.layout import Layout, ExceptionPage, NotFoundPage, UnauthorizedPage | ||
|
||
templatedir('templates') | ||
|
||
class Master(Layout): | ||
grok.name('master') | ||
grok.context(Exception) | ||
|
||
class MyExceptionPage(ExceptionPage): | ||
grok.name('index') | ||
|
||
class MyUnauthorizedPage(UnauthorizedPage): | ||
grok.name('index') | ||
|
||
class MyNotFoundPage(NotFoundPage): | ||
grok.name('index') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
""" | ||
>>> from grokcore.layout import ILayout | ||
>>> from zope.component import getMultiAdapter | ||
>>> from zope.publisher.browser import TestRequest | ||
>>> request = TestRequest() | ||
>>> cow = Cow() | ||
>>> mylayout = getMultiAdapter((request, cow), ILayout) | ||
>>> myview = getMultiAdapter((cow, request), name='myview') | ||
>>> print myview() | ||
<html> | ||
<body> | ||
<div class="layout"><p> My nice Content </p></div> | ||
</body> | ||
</html> | ||
>>> myview | ||
<grokcore.layout.tests.models.page.MyView object at ...> | ||
>>> myview.layout | ||
<grokcore.layout.tests.models.page.Master object at ...> | ||
>>> print myview.content() | ||
<p> My nice Content </p> | ||
""" | ||
import grokcore.component as grok | ||
from grokcore.view import templatedir | ||
from grokcore.layout import Layout, Page | ||
from zope import interface | ||
|
||
templatedir('templates') | ||
|
||
class Cow(grok.Context): | ||
pass | ||
|
||
class Master(Layout): | ||
grok.name('master') | ||
grok.context(Cow) | ||
|
||
class MyView(Page): | ||
grok.context(interface.Interface) | ||
grok.name('myview') | ||
|
||
def render(self): | ||
return "<p> My nice Content </p>" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<html> | ||
<body> | ||
<div class="layout" tal:content="structure view/content"> | ||
here comes the content | ||
</div> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters