This file is indexed.

/usr/share/pyshared/grokcore/component/tests/event/subscriber.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
"""
You can subscribe to events using the @grok.subscribe decorator:

  >>> grok.testing.grok(__name__)
  >>> manfred = Mammoth('Manfred')
  >>> zope.event.notify(ObjectEvent(manfred))
  >>> mammoths
  ['Manfred']
  >>> mammoths2
  ['Manfred']

The decorated event handling function can also be called directly:

  >>> mammothAdded(Mammoth('Max'),None)
  >>> mammoths
  ['Manfred', 'Max']

"""
import zope.event
import grokcore.component as grok
from zope.component.interfaces import IObjectEvent, ObjectEvent

class Mammoth(object):
    def __init__(self, name):
        self.name = name

mammoths = []
mammoths2 = []

@grok.subscribe(Mammoth, IObjectEvent)
def mammothAdded(mammoth, event):
    mammoths.append(mammoth.name)

@grok.subscribe(Mammoth, IObjectEvent)
def mammothAddedInstance(mammoth, event):
    mammoths2.append(mammoth.name)