/usr/share/pyshared/grokcore/component/tests/subscriptions/subscriptions.py is in python-grokcore.component 2.5-0ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 | """
>>> grok.testing.grok(__name__)
>>> cave = Cave('sweet home')
>>> subscriptions = grok.querySubscriptions(cave, ICleaner)
>>> subscriptions
[<grokcore.component.tests.subscriptions.subscriptions.MondayCleaner object at ...>,
<grokcore.component.tests.subscriptions.subscriptions.SaturdayCleaner object at ...>,
<grokcore.component.tests.subscriptions.subscriptions.WednesdayCleaner object at ...>]
>>> _ = map(lambda s: s.work(), subscriptions)
Monday cleaning sweet home!
Saturday cleaning sweet home!
Wednesday cleaning sweet home!
Subscription adapters are not registered as regular adapters:
>>> component.queryAdapter(cave, ICleaner)
"""
import grokcore.component as grok
from zope import interface, component
class Cave(grok.Context):
def __init__(self, name):
self.name = name
class ICleaner(interface.Interface):
def work():
"""Clean that cave.
"""
class MondayCleaner(grok.Subscription):
grok.implements(ICleaner)
def work(self):
print 'Monday cleaning %s!' % self.context.name
class WednesdayCleaner(grok.Subscription):
grok.provides(ICleaner)
def work(self):
print 'Wednesday cleaning %s!' % self.context.name
class SaturdayCleaner(grok.Subscription):
grok.implements(ICleaner)
def work(self):
print 'Saturday cleaning %s!' % self.context.name
|