Skip to content

Commit

Permalink
Python3 support
Browse files Browse the repository at this point in the history
  • Loading branch information
janjaapdriessen committed Sep 28, 2016
1 parent 640eede commit 4147d50
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
10 changes: 5 additions & 5 deletions src/grok/components.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ def flash(self, message, type='message'):
grokcore.message.send(message, type=type, name='session')


@interface.implementer(interfaces.IGrokView)
class View(ViewSupportMixin, grokcore.view.View):
"""The base class for views with templates in Grok applications.
Expand Down Expand Up @@ -145,7 +146,6 @@ class ``MammothList`` occurs in a module ``<src>/animal.py``, for
"""
grok.baseclass()
interface.implements(interfaces.IGrokView)

def application_url(self, name=None, skin=ASIS, data=None):
"""Return the URL of the closest :class:`grok.Application` object in
Expand Down Expand Up @@ -239,6 +239,7 @@ def render(self):
render.base_method = True


@interface.implementer(interfaces.IGrokForm)
class Form(ViewSupportMixin, grokcore.formlib.Form):
"""The base class for forms in Grok applications.
Expand All @@ -254,25 +255,24 @@ class Form(ViewSupportMixin, grokcore.formlib.Form):
"""
grok.baseclass()
interface.implements(interfaces.IGrokForm)


@interface.implementer(interfaces.IGrokForm)
class AddForm(ViewSupportMixin, grokcore.formlib.AddForm):
"""Base class for add forms in Grok applications."""
grok.baseclass()
interface.implements(interfaces.IGrokForm)


@interface.implementer(interfaces.IGrokForm)
class DisplayForm(ViewSupportMixin, grokcore.formlib.DisplayForm):
"""Base class for display forms in Grok applications."""
grok.baseclass()
interface.implements(interfaces.IGrokForm)


@interface.implementer(interfaces.IGrokForm)
class EditForm(ViewSupportMixin, grokcore.formlib.EditForm):
"""Base class for edit forms in Grok applications."""
grok.baseclass()
interface.implements(interfaces.IGrokForm)


class Layout(ViewSupportMixin, grokcore.layout.Layout):
Expand Down
5 changes: 3 additions & 2 deletions src/grok/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,12 @@
conveniently provided to be used in your own application.
"""
from zope.interface import implements
from zope.interface import implementer
from zope.component.interfaces import ObjectEvent
from grokcore.site.interfaces import ApplicationAddedEvent # BBB
from grok.interfaces import IDatabaseCreatedEvent


@implementer(IDatabaseCreatedEvent)
class DatabaseCreatedEvent(ObjectEvent):
implements(IDatabaseCreatedEvent)
pass
7 changes: 4 additions & 3 deletions src/grok/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
##############################################################################
"""Grok test helpers.
"""
from __future__ import print_function
import sys
from zope.configuration.config import ConfigurationMachine
from grokcore.component import zcml
Expand Down Expand Up @@ -58,7 +59,7 @@ def warn(message, category=None, stacklevel=1):
When zope.deprecation is fixed, this warn function can be removed again.
"""
print "From grok.testing's warn():"
print("From grok.testing's warn():")

frame = sys._getframe(stacklevel)
path = frame.f_globals['__file__']
Expand All @@ -70,10 +71,10 @@ def warn(message, category=None, stacklevel=1):
for i in range(lineno):
line = file.readline()

print "%s:%s: %s: %s\n %s" % (
print("{}:{}: {}: {}\n {}".format(
path,
frame.f_lineno,
category.__name__,
message,
line.strip(),
)
))

0 comments on commit 4147d50

Please sign in to comment.