Skip to content

Commit

Permalink
Use print function
Browse files Browse the repository at this point in the history
  • Loading branch information
janjaapdriessen committed Sep 28, 2016
1 parent 5293b8a commit f952b91
Show file tree
Hide file tree
Showing 29 changed files with 101 additions and 99 deletions.
2 changes: 1 addition & 1 deletion src/grok/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
##############################################################################
"""Grok
"""
from zope.interface import implements
from zope.component import adapts

from martian import ClassGrokker, InstanceGrokker, GlobalGrokker
Expand All @@ -29,6 +28,7 @@
from grokcore.component import queryOrderedMultiSubscriptions

from grokcore.component.decorators import subscribe, adapter, implementer
from grokcore.component import implements

from grokcore.component.directive import context, name, title, description
from grokcore.component.directive import provides, direct
Expand Down
4 changes: 2 additions & 2 deletions src/grok/ftests/catalog/addform.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@
>>> browser.getControl("Add entry").click()
>>> browser.open("http://localhost/zoo/ellie")
>>> print browser.contents
>>> print(browser.contents)
Hi, my name is Ellie the Mammoth, and I\'m "Really small"
Let's ensure the catalog has actually indexed the object with the
right value:
>>> browser.open("http://localhost/zoo/search")
>>> print browser.contents
>>> print(browser.contents)
We found Ellie!
"""
Expand Down
2 changes: 1 addition & 1 deletion src/grok/ftests/chameleon/chameleon_available.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
>>> getRootFolder()["mammoth"] = Mammoth()
>>> browser = Browser()
>>> browser.open("http://localhost/mammoth/@@index")
>>> print browser.contents
>>> print(browser.contents)
<html>Mammoth</html>
"""
Expand Down
14 changes: 7 additions & 7 deletions src/grok/ftests/errorviews/errorviews.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
>>> from zope.component import getMultiAdapter
>>> from zope.publisher.browser import TestRequest
>>> view = getMultiAdapter((Exception(), TestRequest()), name='index')
>>> print view()
>>> print(view())
A system error occurred.
Error views no longer by default provide ISystemErrorView. It would result in
Expand All @@ -20,14 +20,14 @@
>>> request = TestRequest()
>>> error = NotFound(object(), request)
>>> view = getMultiAdapter((error, request), name='index')
>>> print view()
>>> print(view())
The requested resource can not be found.
>>> from zope.security.interfaces import Unauthorized
>>> request = TestRequest()
>>> request.setPrincipal(MockPrincipal())
>>> view = getMultiAdapter((Unauthorized(), request), name='index')
>>> print view()
>>> print(view())
Access to the requested resource is forbidden.
The default views can be selectively overridden in your application::
Expand All @@ -41,7 +41,7 @@
True
>>> view = getMultiAdapter((Exception(), TestRequest()), name='index')
>>> print view()
>>> print(view())
This is my idea of an exception view.
>>> from grok import NotFoundView
Expand All @@ -54,7 +54,7 @@
>>> request = TestRequest()
>>> error = NotFound(object(), request)
>>> view = getMultiAdapter((error, request), name='index')
>>> print view()
>>> print(view()))
This is my idea of a not found view.
>>> from grok import UnauthorizedView
Expand All @@ -67,7 +67,7 @@
>>> request = TestRequest()
>>> request.setPrincipal(MockPrincipal())
>>> view = getMultiAdapter((Unauthorized(), request), name='index')
>>> print view()
>>> print(view())
This is my idea of an unauthorized view.
>>> class WithTemplate(ExceptionView):
Expand All @@ -76,7 +76,7 @@
True
>>> view = getMultiAdapter((Exception(), TestRequest()), name='index')
>>> print view()
>>> print(view())
<html>
<body>
<h1>Something went wrong!</h1>
Expand Down
6 changes: 3 additions & 3 deletions src/grok/ftests/form/form.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@
>>> browser = Browser()
>>> browser.handleErrors = False
>>> browser.open('http://localhost/world/arthur')
>>> print browser.contents
>>> print(browser.contents)
<p> Test display: application http://localhost/world </p>
Same for the edit form::
>>> browser.open('http://localhost/world/arthur/@@edit')
>>> print browser.contents
>>> print(browser.contents)
<p> Test edit: application http://localhost/world </p>
Expand Down Expand Up @@ -47,7 +47,7 @@ class Index(grok.DisplayForm):


class Edit(grok.EditForm):

grok.context(Mammoth)

edit = grok.PageTemplate("""
Expand Down
10 changes: 5 additions & 5 deletions src/grok/ftests/forms/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
FormPage:
>>> myform = getMultiAdapter((cow, request), name='myformpage')
>>> print myform()
>>> print(myform())
<html>
<body>
<div class="layout"><form action="http://127.0.0.1" method="post"
Expand Down Expand Up @@ -52,7 +52,7 @@
Display form:
>>> myview = getMultiAdapter((cow, request), name='myview')
>>> print myview()
>>> print(myview())
<html>
<body>
<div class="layout">...
Expand All @@ -72,7 +72,7 @@
<grok.ftests.forms.forms.MyView object at ...>
>>> myview.layout
<grok.ftests.forms.forms.Master object at ...>
>>> print myview.content()
>>> print(myview.content())
<table class="listing">
<thead>
<tr>
Expand Down Expand Up @@ -103,7 +103,7 @@
Edit form:
>>> myeditview = getMultiAdapter((cow, request), name='myeditview')
>>> print myeditview()
>>> print(myeditview())
<html>
<body>
<div class="layout"><form action="http://127.0.0.1" method="post"
Expand Down Expand Up @@ -147,7 +147,7 @@
<grok.ftests.forms.forms.MyEditView object at ...>
>>> myeditview.layout
<grok.ftests.forms.forms.Master object at ...>
>>> print myeditview.content()
>>> print(myeditview.content())
<form action="http://127.0.0.1" method="post"
class="edit-form" enctype="multipart/form-data">
...<span>Color</span>...
Expand Down
7 changes: 4 additions & 3 deletions src/grok/ftests/lifecycle/create_application.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
As we can see, the events are effectively trigged, and in the right
order. The function returns the persisted application.
>>> print app
>>> print(app)
<grok.ftests.lifecycle.create_application.Cave object at ...>
>>> print app.__parent__
>>> print(app.__parent__)
<zope.site.folder.Folder object at ...>
However, if an error occurs during the creation process, the exception
Expand All @@ -48,6 +48,7 @@
WrongType: <class 'grok.ftests.lifecycle.create_application.Mammoth'>
"""
from __future__ import print_function
import grok


Expand All @@ -67,4 +68,4 @@ class Cave(grok.Container, grok.Application):
@grok.subscribe(Cave, grok.IObjectAddedEvent)
@grok.subscribe(Cave, grok.IApplicationAddedEvent)
def EventPrinter(application, event):
print application.__class__.__name__, event
print(application.__class__.__name__, event)
4 changes: 2 additions & 2 deletions src/grok/ftests/lifecycle/lifecycle_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,6 @@ class TuskIndex(grok.Indexes):
def CatalogTester(application, event):
catalog = queryUtility(ICatalog, context=application)
if catalog is None:
print "Catalog can not be found !"
print("Catalog can not be found !")
else:
print catalog
print(catalog)
2 changes: 1 addition & 1 deletion src/grok/ftests/security/grok_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
>>> browser = Browser()
>>> browser.handleErrors = False
>>> browser.open('http://localhost/app/@@index')
>>> print browser.contents
>>> print(browser.contents)
Hello world
"""
Expand Down
4 changes: 2 additions & 2 deletions src/grok/ftests/security/json.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
We can access the public method just fine::
>>> browser.open('http://localhost/stomp')
>>> print browser.contents
>>> print(browser.contents)
{"Manfred stomped.": ""}
We cannot access the protected method however::
Expand All @@ -21,7 +21,7 @@
>>> browser.addHeader('Authorization', 'Basic mgr:mgrpw')
>>> browser.open('http://localhost/dance')
>>> print browser.contents
>>> print(browser.contents)
{"Manfred doesn't like to dance.": ""}
"""
Expand Down
10 changes: 5 additions & 5 deletions src/grok/ftests/security/preserve_permissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
`zope.ManageContent` and should not be visible to unauthenticated
users. Instead we are asked to authenticate ourselves::
>>> print http('GET /@@contents.html HTTP/1.1')
>>> print(http('GET /@@contents.html HTTP/1.1'))
HTTP/1.0 401 Unauthorized
...
Expand All @@ -44,7 +44,7 @@
Now there is a ``contents.html`` view available for our application,
which is protected by default::
>>> print http('GET /app/@@contents.html HTTP/1.1')
>>> print(http('GET /app/@@contents.html HTTP/1.1'))
HTTP/1.0 401 Unauthorized
...
Expand All @@ -56,7 +56,7 @@
>>> root_perms = IPrincipalPermissionManager(root)
>>> root_perms.grantPermissionToPrincipal('zope.ManageContent',
... 'zope.anybody')
>>> print http('GET /@@contents.html HTTP/1.1')
>>> print(http('GET /@@contents.html HTTP/1.1'))
HTTP/1.0 200 Ok
...
Expand All @@ -65,7 +65,7 @@
>>> from zope.app.wsgi.testlayer import Browser
>>> browser = Browser()
>>> browser.open('http://localhost/app')
>>> print browser.contents
>>> print(browser.contents)
Moo!
While the manage view is locked::
Expand All @@ -79,7 +79,7 @@
>>> browser.addHeader('Authorization', 'Basic mgr:mgrpw')
>>> browser.open('http://localhost/app/@@manage')
>>> print browser.contents
>>> print(browser.contents)
Woo!
"""
Expand Down
6 changes: 3 additions & 3 deletions src/grok/ftests/security/roles.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@
... 'paint.PaintingOwner', 'zope.anybody')
>>> browser.open("http://localhost/@@cavepainting")
>>> print browser.contents
>>> print(browser.contents)
What a beautiful painting.
>>> browser.open("http://localhost/@@editcavepainting")
>>> print browser.contents
>>> print(browser.contents)
Let's make it even prettier.
>>> browser.open("http://localhost/@@erasecavepainting")
>>> print browser.contents
>>> print(browser.contents)
Oops, mistake, let's erase it.
>>> browser.open("http://localhost/@@approvecavepainting")
Expand Down
2 changes: 1 addition & 1 deletion src/grok/ftests/security/security_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
Now we can watch the view::
>>> browser.open('http://localhost/app/@@index')
>>> print browser.contents
>>> print(browser.contents)
Hello from index
"""
Expand Down
20 changes: 10 additions & 10 deletions src/grok/ftests/traversal/containertraverse.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,35 +13,35 @@
>>> browser = Browser()
>>> browser.handleErrors = False
>>> browser.open("http://localhost/herd/special")
>>> print browser.contents
>>> print(browser.contents)
special view
>>> browser.open("http://localhost/herd/special/index")
>>> print browser.contents
>>> print(browser.contents)
special view
Even if we have a container item called 'special', we should still
get our special object:
>>> herd['special'] = Mammoth('Special invisible mammoth')
>>> browser.open("http://localhost/herd/special")
>>> print browser.contents
>>> print(browser.contents)
special view
>>> browser.open("http://localhost/herd/special/index")
>>> print browser.contents
>>> print(browser.contents)
special view
The fall-back behavior should work for items that aren't traversed:
>>> browser.open("http://localhost/herd/manfred")
>>> print browser.contents
>>> print(browser.contents)
<html>
<body>
<h1>Hello, Manfred!</h1>
</body>
</html>
>>> browser.open("http://localhost/herd/ellie")
>>> print browser.contents
>>> print(browser.contents)
<html>
<body>
<h1>Hello, Ellie!</h1>
Expand All @@ -53,7 +53,7 @@
>>> herd['subherd'] = Herd()
>>> browser.open("http://localhost/herd/subherd")
>>> print browser.contents
>>> print(browser.contents)
A herd
"""
Expand All @@ -65,7 +65,7 @@ def traverse(self, name):
if name == 'special':
return Special()
return None

class HerdIndex(grok.View):
grok.context(Herd)
grok.name('index')
Expand All @@ -84,7 +84,7 @@ class Special(grok.Model):
class SpecialIndex(grok.View):
grok.context(Special)
grok.name('index')

def render(self):
return "special view"

Expand Down
Loading

0 comments on commit f952b91

Please sign in to comment.