Skip to content

Commit

Permalink
flake8
Browse files Browse the repository at this point in the history
  • Loading branch information
janjaapdriessen committed Jun 10, 2020
1 parent ce6d2e6 commit 96413ca
Show file tree
Hide file tree
Showing 99 changed files with 426 additions and 143 deletions.
31 changes: 15 additions & 16 deletions src/grok/components.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,9 +262,11 @@ class EditForm(ViewSupportMixin, grokcore.formlib.EditForm):
class Layout(ViewSupportMixin, grokcore.layout.Layout):
grok.baseclass()


class Page(ViewSupportMixin, grokcore.layout.Page):
grok.baseclass()


# Default forms for form without the html and body tags
default_form_template = grokcore.view.PageTemplateFile(
os.path.join('templates', 'default_edit_form.pt'))
Expand All @@ -276,6 +278,7 @@ class Page(ViewSupportMixin, grokcore.layout.Page):

default_display_template.__grok_name__ = 'default_display_form'


class LayoutAwareFormPage(grokcore.layout.components.LayoutAware):
"""A mixin to make form aware of layouts.
"""
Expand All @@ -297,43 +300,39 @@ def __call__(self):


class FormPage(
ViewSupportMixin,
LayoutAwareFormPage,
grokcore.formlib.Form
):
ViewSupportMixin,
LayoutAwareFormPage,
grokcore.formlib.Form):
"""A form base class.
"""
grok.baseclass()
template = default_form_template


class AddFormPage(
ViewSupportMixin,
LayoutAwareFormPage,
grokcore.formlib.AddForm
):
ViewSupportMixin,
LayoutAwareFormPage,
grokcore.formlib.AddForm):
"""Base add form.
"""
grok.baseclass()
template = default_form_template


class EditFormPage(
ViewSupportMixin,
LayoutAwareFormPage,
grokcore.formlib.EditForm
):
ViewSupportMixin,
LayoutAwareFormPage,
grokcore.formlib.EditForm):
"""Base edit form.
"""
grok.baseclass()
template = default_form_template


class DisplayFormPage(
ViewSupportMixin,
LayoutAwareFormPage,
grokcore.formlib.DisplayForm
):
ViewSupportMixin,
LayoutAwareFormPage,
grokcore.formlib.DisplayForm):
"""Base display form.
"""
grok.baseclass()
Expand Down
7 changes: 7 additions & 0 deletions src/grok/ftests/catalog/addform.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,28 +39,34 @@
from zope.catalog.interfaces import ICatalog
from zope.catalog.field import FieldIndex


def setup_catalog(catalog):
catalog['name'] = FieldIndex('name', IMammoth)


class Zoo(grok.Site, grok.Container):
grok.local_utility(IntIds, provides=IIntIds)
grok.local_utility(Catalog, provides=ICatalog, setup=setup_catalog)


class IMammoth(interface.Interface):
name = schema.TextLine(title=u"Name")
size = schema.TextLine(title=u"Size")


@grok.implementer(IMammoth)
class Mammoth(grok.Model):
pass


class Index(grok.View):
grok.context(Mammoth)

def render(self):
return 'Hi, my name is %s, and I\'m "%s"' % (self.context.name,
self.context.size)


class Search(grok.View):
grok.context(Zoo)

Expand All @@ -72,6 +78,7 @@ def render(self):
return 'We found Ellie!'
return "Couldn't find Ellie."


class AddMammoth(grok.AddForm):
grok.context(Zoo)

Expand Down
2 changes: 2 additions & 0 deletions src/grok/ftests/chameleon/chameleon_available.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@

grok.templatedir('templates')


class Mammoth(grok.Model):
pass


class Index(grok.View):
grok.context(Mammoth)
grok.template('available')
2 changes: 2 additions & 0 deletions src/grok/ftests/errorviews/errorviews.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,11 @@
"""
import grok


class MockPrincipal(object):
id = 'mockprincipal'


exceptionview_template = grok.PageTemplate("""\
<html>
<body>
Expand Down
3 changes: 3 additions & 0 deletions src/grok/ftests/form/form.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import grok
from zope import schema


class IceWorld(grok.Application, grok.Container):
pass

Expand All @@ -40,6 +41,7 @@ class Index(grok.DisplayForm):

grok.context(Mammoth)


index = grok.PageTemplate("""
<p>
Test display: application <tal:replace tal:replace="view/application_url" />
Expand All @@ -50,6 +52,7 @@ class Edit(grok.EditForm):

grok.context(Mammoth)


edit = grok.PageTemplate("""
<p>
Test edit: application <tal:replace tal:replace="view/application_url" />
Expand Down
5 changes: 2 additions & 3 deletions src/grok/ftests/forms/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,7 @@
... value="globally dark" ...
... value="Apply" ...
</form>
"""
""" # noqa: E501
import grokcore.component as grok

from grokcore.view import templatedir
Expand Down Expand Up @@ -188,5 +186,6 @@ class MyView(DisplayFormPage):
class MyEditView(EditFormPage):
grok.context(Cow)


class MyFormPage(FormPage):
grok.context(Cow)
2 changes: 1 addition & 1 deletion src/grok/ftests/lifecycle/create_application.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
...
zope.schema._bootstrapinterfaces.WrongType: <class 'grok.ftests.lifecycle.create_application.Mammoth'>
"""
""" # noqa: E501
from __future__ import print_function
import grok

Expand Down
2 changes: 2 additions & 0 deletions src/grok/ftests/security/grok_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@
"""
import grok


class App(grok.Application, grok.Container):
pass


class Index(grok.View):
def render(self):
return "Hello world"
1 change: 1 addition & 0 deletions src/grok/ftests/security/json.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import grok
import zope.interface


class MammothJSON(grok.JSON):
grok.context(zope.interface.Interface)

Expand Down
5 changes: 5 additions & 0 deletions src/grok/ftests/security/preserve_permissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,17 +85,22 @@
"""
import grok


class ManageApp(grok.Permission):
grok.name('app.Manage')


class App(grok.Application, grok.Container):
pass


class Index(grok.View):
def render(self):
return 'Moo!'


class Manage(grok.View):
grok.require('app.Manage')

def render(self):
return 'Woo!'
9 changes: 9 additions & 0 deletions src/grok/ftests/security/roles.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,24 +46,30 @@
import grok
import zope.interface


class ViewPermission(grok.Permission):
grok.name('paint.ViewPainting')


class EditPermission(grok.Permission):
grok.name('paint.EditPainting')


class ErasePermission(grok.Permission):
grok.name('paint.ErasePainting')


class ApprovePermission(grok.Permission):
grok.name('paint.ApprovePainting')


class PaintingOwner(grok.Role):
grok.name('paint.PaintingOwner')
grok.title('Painting Owner')
grok.permissions(
'paint.ViewPainting', 'paint.EditPainting', 'paint.ErasePainting')


class CavePainting(grok.View):

grok.context(zope.interface.Interface)
Expand All @@ -72,6 +78,7 @@ class CavePainting(grok.View):
def render(self):
return 'What a beautiful painting.'


class EditCavePainting(grok.View):

grok.context(zope.interface.Interface)
Expand All @@ -80,6 +87,7 @@ class EditCavePainting(grok.View):
def render(self):
return 'Let\'s make it even prettier.'


class EraseCavePainting(grok.View):

grok.context(zope.interface.Interface)
Expand All @@ -88,6 +96,7 @@ class EraseCavePainting(grok.View):
def render(self):
return 'Oops, mistake, let\'s erase it.'


class ApproveCavePainting(grok.View):

grok.context(zope.interface.Interface)
Expand Down
4 changes: 3 additions & 1 deletion src/grok/ftests/security/security_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,15 @@
>>> print(browser.contents)
Hello from index
"""
""" # noqa: E501
import grok
from zope.publisher.browser import BrowserPage


class App(grok.Application, grok.Container):
pass


class Index(BrowserPage):
def __call__(self):
return 'Hello from index'
40 changes: 21 additions & 19 deletions src/grok/ftests/test_grok_functional.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import re
import unittest, doctest
import unittest
import doctest
import grok
import grok.testing

Expand All @@ -11,10 +11,11 @@


class Layer(
zope.testbrowser.wsgi.TestBrowserLayer,
zope.app.wsgi.testlayer.BrowserLayer):
zope.testbrowser.wsgi.TestBrowserLayer,
zope.app.wsgi.testlayer.BrowserLayer):
pass


layer = Layer(grok)


Expand Down Expand Up @@ -58,30 +59,31 @@ def suiteFromPackage(name):
wsgi_app=layer.make_wsgi_app,
),
optionflags=(
doctest.ELLIPSIS+
doctest.NORMALIZE_WHITESPACE+
doctest.REPORT_NDIFF+
doctest.ELLIPSIS +
doctest.NORMALIZE_WHITESPACE +
doctest.REPORT_NDIFF +
renormalizing.IGNORE_EXCEPTION_MODULE_IN_PYTHON2)
)
test.layer = layer
suite.addTest(test)
return suite


def test_suite():
suite = unittest.TestSuite()
for name in [
'catalog',
'chameleon',
'errorviews',
'form',
'forms',
'lifecycle',
'security',
'site',
'traversal',
'url',
'viewlet',
]:
'catalog',
'chameleon',
'errorviews',
'form',
'forms',
'lifecycle',
'security',
'site',
'traversal',
'url',
'viewlet',
]:
suite.addTest(suiteFromPackage(name))
return suite

Expand Down

0 comments on commit 96413ca

Please sign in to comment.