Skip to content

Commit

Permalink
Replace the use of grok.implements() with the @grok.implementer()
Browse files Browse the repository at this point in the history
… directive throughout.
  • Loading branch information
janwijbrand committed Jan 17, 2018
1 parent 482e77e commit 6500c1d
Show file tree
Hide file tree
Showing 26 changed files with 71 additions and 47 deletions.
4 changes: 2 additions & 2 deletions CHANGES.txt
Expand Up @@ -4,8 +4,8 @@ Grok changes
3.0.1 (unreleased)
==================

- Nothing changed yet.

- Replace the use of `grok.implements()` with the `@grok.implementer()`
directive throughout.

3.0.0 (2018-01-16)
==================
Expand Down
3 changes: 2 additions & 1 deletion src/grok/ftests/catalog/addform.py
Expand Up @@ -50,8 +50,9 @@ class IMammoth(interface.Interface):
name = schema.TextLine(title=u"Name")
size = schema.TextLine(title=u"Size")

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

class Index(grok.View):
grok.context(Mammoth)
Expand Down
2 changes: 1 addition & 1 deletion src/grok/ftests/forms/forms.py
Expand Up @@ -171,8 +171,8 @@ class ICowProperties(interface.Interface):
color = schema.TextLine(title=u"Color")


@grok.implementer(ICowProperties)
class Cow(grok.Context):
grok.implements(ICowProperties)
color = u"globally dark"


Expand Down
9 changes: 6 additions & 3 deletions src/grok/ftests/url/application.py
Expand Up @@ -67,14 +67,17 @@ class Second(grok.View):
def render(self):
return self.application_url('second')

@grok.implementer(IMarker)
class Cave(grok.Application, grok.Container):
grok.implements(IMarker)
pass

@grok.implementer(IMarker)
class CaveMan(grok.Model):
grok.implements(IMarker)
pass

@grok.implementer(IMarker)
class Corridors(grok.Container):
grok.implements(IMarker)
pass

class IMammothSkin(IDefaultBrowserLayer):
grok.skin('mammothskin')
Expand Down
5 changes: 3 additions & 2 deletions src/grok/tests/adapter/adapter.py
Expand Up @@ -25,12 +25,13 @@ class Cave(grok.Model):
class IHome(interface.Interface):
pass

@grok.implementer(IHome)
class Home(grok.Adapter):
grok.implements(IHome)
pass

class IFireplace(interface.Interface):
pass

@grok.implementer(IFireplace, IHome)
class Fireplace(grok.Adapter):
grok.implements(IFireplace, IHome)
grok.provides(IFireplace)
5 changes: 3 additions & 2 deletions src/grok/tests/adapter/adapterdecorator.py
Expand Up @@ -49,12 +49,13 @@ class IMoreHome(interface.Interface):
class IYetAnotherHome(interface.Interface):
pass

@grok.implementer(ICave)
class Cave(grok.Model):
grok.implements(ICave)
pass

@grok.implementer(IHome)
class Home(object):
grok.implements(IHome)
pass

@grok.adapter(Cave)
@grok.implementer(IHome)
Expand Down
3 changes: 2 additions & 1 deletion src/grok/tests/adapter/alphabetical.py
Expand Up @@ -22,5 +22,6 @@ class ZCave(grok.Model):
class IHome(interface.Interface):
pass

@grok.implementer(IHome)
class Home(grok.Adapter):
grok.implements(IHome)
pass
2 changes: 1 addition & 1 deletion src/grok/tests/adapter/classcontext.py
Expand Up @@ -24,6 +24,6 @@ class Club(grok.Model):
class IHome(interface.Interface):
pass

@grok.implementer(IHome)
class Home(grok.Adapter):
grok.implements(IHome)
grok.context(Cave)
2 changes: 1 addition & 1 deletion src/grok/tests/adapter/classcontextimported.py
Expand Up @@ -19,6 +19,6 @@
class IPainting(interface.Interface):
pass

@grok.implementer(IPainting)
class Painting(grok.Adapter):
grok.implements(IPainting)
grok.context(Cave)
3 changes: 2 additions & 1 deletion src/grok/tests/adapter/implementsmany.py
Expand Up @@ -21,5 +21,6 @@ class IHome(interface.Interface):
class IFireplace(interface.Interface):
pass

@grok.implementer(IHome, IFireplace)
class Home(grok.Adapter):
grok.implements(IHome, IFireplace)
pass
2 changes: 1 addition & 1 deletion src/grok/tests/adapter/importedmodel2.py
Expand Up @@ -16,9 +16,9 @@
class IPainting(interface.Interface):
pass

@grok.implementer(IPainting)
class Painting(grok.Adapter):
"""
Grokking of this should fail because there's no model (only an
imported one which doesn't count).
"""
grok.implements(IPainting)
8 changes: 5 additions & 3 deletions src/grok/tests/adapter/interface.py
Expand Up @@ -27,15 +27,17 @@
class ICave(interface.Interface):
pass

@grok.implementer(ICave)
class Cave(grok.Model):
grok.implements(ICave)
pass

@grok.implementer(ICave)
class Hole(grok.Model):
grok.implements(ICave)
pass

class IHome(interface.Interface):
pass

@grok.implementer(IHome)
class Home(grok.Adapter):
grok.implements(IHome)
grok.context(ICave)
9 changes: 6 additions & 3 deletions src/grok/tests/adapter/interfacemodule.py
Expand Up @@ -27,16 +27,19 @@
class ICave(interface.Interface):
pass

@grok.implementer(ICave)
class Cave(grok.Model):
grok.implements(ICave)
pass

@grok.implementer(ICave)
class Hole(grok.Model):
grok.implements(ICave)
pass

grok.context(ICave)

class IHome(interface.Interface):
pass

@grok.implementer(IHome)
class Home(grok.Adapter):
grok.implements(IHome)
pass
3 changes: 2 additions & 1 deletion src/grok/tests/adapter/modulecontext.py
Expand Up @@ -26,5 +26,6 @@ class Club(grok.Model):
class IHome(interface.Interface):
pass

@grok.implementer(IHome)
class Home(grok.Adapter):
grok.implements(IHome)
pass
3 changes: 2 additions & 1 deletion src/grok/tests/adapter/modulecontextimported.py
Expand Up @@ -21,5 +21,6 @@
class IPainting(interface.Interface):
pass

@grok.implementer(IPainting)
class Painting(grok.Adapter):
grok.implements(IPainting)
pass
6 changes: 3 additions & 3 deletions src/grok/tests/adapter/multiadapter.py
Expand Up @@ -60,17 +60,17 @@ class Fireplace(grok.Model):
class IHome(interface.Interface):
pass

@grok.implementer(IHome)
class Home(grok.MultiAdapter):
grok.adapts(Cave, Fireplace)
grok.implements(IHome)

def __init__(self, cave, fireplace):
self.cave = cave
self.fireplace = fireplace

@grok.implementer(IHome)
class Home2(grok.MultiAdapter):
grok.adapts(Cave, Fireplace)
grok.implements(IHome)
grok.name('home2')

def __init__(self, cave, fireplace):
Expand All @@ -80,9 +80,9 @@ def __init__(self, cave, fireplace):
class IFireplace(interface.Interface):
pass

@grok.implementer(IHome, IFireplace)
class Home3(grok.MultiAdapter):
grok.adapts(Cave, Fireplace)
grok.implements(IHome, IFireplace)
grok.provides(IHome)
grok.name('home3')

Expand Down
3 changes: 2 additions & 1 deletion src/grok/tests/adapter/multiadaptsnone.py
Expand Up @@ -14,5 +14,6 @@
class IHome(interface.Interface):
pass

@grok.implementer(IHome)
class Home(grok.MultiAdapter):
grok.implements(IHome)
pass
3 changes: 2 additions & 1 deletion src/grok/tests/adapter/multiple.py
Expand Up @@ -19,5 +19,6 @@ class Club(grok.Model):
class IHome(interface.Interface):
pass

@grok.implementer(IHome)
class Home(grok.Adapter):
grok.implements(IHome)
pass
2 changes: 1 addition & 1 deletion src/grok/tests/adapter/namedadapter.py
Expand Up @@ -26,6 +26,6 @@ class Cave(grok.Model):
class IHome(interface.Interface):
pass

@grok.implementer(IHome)
class Home(grok.Adapter):
grok.implements(IHome)
grok.name('home')
3 changes: 2 additions & 1 deletion src/grok/tests/adapter/nomodel.py
Expand Up @@ -13,5 +13,6 @@
class IHome(interface.Interface):
pass

@grok.implementer(IHome)
class Home(grok.Adapter):
grok.implements(IHome)
pass
2 changes: 1 addition & 1 deletion src/grok/tests/adapter/oldstyleclass.py
Expand Up @@ -20,6 +20,6 @@ class Cave:
class IHome(interface.Interface):
pass

@grok.implementer(IHome)
class Home(grok.Adapter):
grok.implements(IHome)
grok.context(Cave)
3 changes: 2 additions & 1 deletion src/grok/tests/adapter/order.py
Expand Up @@ -19,8 +19,9 @@
class IHome(interface.Interface):
pass

@grok.implementer(IHome)
class Home(grok.Adapter):
grok.implements(IHome)
pass

class Cave(grok.Model):
pass
6 changes: 4 additions & 2 deletions src/grok/tests/directive/multipletimes.py
Expand Up @@ -36,11 +36,13 @@ class IClub(interface.Interface):
class ICave(interface.Interface):
pass

@grok.implementer(IClub)
class Club(object):
grok.implements(IClub)
pass

@grok.implementer(ICave)
class Cave(object):
grok.implements(ICave)
pass

grok.global_utility(Club, provides=IClub, name='foo')
grok.global_utility(Cave)
3 changes: 2 additions & 1 deletion src/grok/tests/utility/implementsmany.py
Expand Up @@ -16,5 +16,6 @@ class IClub(interface.Interface):
class ISpikyClub(interface.Interface):
pass

@grok.implementer(IClub, ISpikyClub)
class Club(grok.GlobalUtility):
grok.implements(IClub, ISpikyClub)
pass
4 changes: 2 additions & 2 deletions src/grok/tests/utility/implementsmany2.py
Expand Up @@ -16,8 +16,8 @@ class IClub(interface.Interface):
class ISpikyClub(interface.Interface):
pass

@grok.implementer(IClub, ISpikyClub)
class Club(object):
grok.implements(IClub, ISpikyClub)
pass

grok.global_utility(Club)

20 changes: 11 additions & 9 deletions src/grok/tests/utility/utility.py
Expand Up @@ -145,31 +145,31 @@ class INightClub(interface.Interface):
class IClubMaker(interface.Interface):
pass

@grok.implementer(IClub)
class NormalClub(grok.GlobalUtility):
grok.implements(IClub)
pass

@grok.implementer(IClub)
class HugeClub(grok.GlobalUtility):
grok.implements(IClub)
grok.name('huge')

@grok.implementer(ISpikyClub)
class SpikyClub(grok.GlobalUtility):
grok.implements(ISpikyClub)
grok.provides(IClub)
grok.name('spiky')

@grok.implementer(INightClub, ISpikyClub)
class NightClub(grok.GlobalUtility):
grok.implements(INightClub, ISpikyClub)
grok.provides(INightClub)

@grok.implementer(ISmallClub, ITinyClub)
class SmallClub(grok.GlobalUtility):
grok.implements(ISmallClub, ITinyClub)
grok.provides(ISmallClub)
grok.name('tiny')


@interface.provider(IClubMaker)
@grok.implementer(IClub)
class ClubMaker(grok.GlobalUtility):
grok.implements(IClub)
grok.direct()
grok.name('maker')

Expand All @@ -179,11 +179,13 @@ class IFireplace(interface.Interface):
class IHome(interface.Interface):
pass

@grok.implementer(IFireplace)
class Fireplace(object):
grok.implements(IFireplace)
pass

@grok.implementer(IFireplace, IHome)
class Home(object):
grok.implements(IFireplace, IHome)
pass

grok.global_utility(Fireplace)
grok.global_utility(Fireplace, name='hot')
Expand Down

0 comments on commit 6500c1d

Please sign in to comment.