summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris McDonough <chrism@plope.com>2012-11-21 07:48:22 -0500
committerChris McDonough <chrism@plope.com>2012-11-21 07:48:22 -0500
commit9e5c8aab88c426d8e3e9b611690234edd5861021 (patch)
treed8f0ea93056e160a5082a0143ff8697ad8b6d034
parent991440e9130b3c3a139e0fbfb6a43b791faf7bd3 (diff)
downloadpyramid-9e5c8aab88c426d8e3e9b611690234edd5861021.tar.gz
pyramid-9e5c8aab88c426d8e3e9b611690234edd5861021.tar.bz2
pyramid-9e5c8aab88c426d8e3e9b611690234edd5861021.zip
missed adding this file
-rw-r--r--pyramid/tests/pkgs/eventonly/__init__.py64
1 files changed, 64 insertions, 0 deletions
diff --git a/pyramid/tests/pkgs/eventonly/__init__.py b/pyramid/tests/pkgs/eventonly/__init__.py
new file mode 100644
index 000000000..7ae93ada6
--- /dev/null
+++ b/pyramid/tests/pkgs/eventonly/__init__.py
@@ -0,0 +1,64 @@
+from pyramid.view import view_config
+from pyramid.events import subscriber
+
+class Yup(object):
+ def __init__(self, val, config):
+ self.val = val
+
+ def text(self):
+ return 'path_startswith = %s' % (self.val,)
+
+ phash = text
+
+ def __call__(self, event):
+ return getattr(event.response, 'yup', False)
+
+class Foo(object):
+ def __init__(self, response):
+ self.response = response
+
+class Bar(object):
+ pass
+
+@subscriber(Foo)
+def foo(event):
+ event.response.text += 'foo '
+
+@subscriber(Foo, yup=True)
+def fooyup(event):
+ event.response.text += 'fooyup '
+
+@subscriber([Foo, Bar])
+def foobar(event):
+ event.response.text += 'foobar '
+
+@subscriber([Foo, Bar])
+def foobar2(event, context):
+ event.response.text += 'foobar2 '
+
+@subscriber([Foo, Bar], yup=True)
+def foobaryup(event):
+ event.response.text += 'foobaryup '
+
+@subscriber([Foo, Bar], yup=True)
+def foobaryup2(event, context):
+ event.response.text += 'foobaryup2 '
+
+@view_config(name='sendfoo')
+def sendfoo(request):
+ response = request.response
+ response.yup = True
+ request.registry.notify(Foo(response))
+ return response
+
+@view_config(name='sendfoobar')
+def sendfoobar(request):
+ response = request.response
+ response.yup = True
+ request.registry.notify(Foo(response), Bar())
+ return response
+
+def includeme(config):
+ config.add_subscriber_predicate('yup', Yup)
+ config.scan('pyramid.tests.pkgs.eventonly')
+