diff options
| author | Chris McDonough <chrism@agendaless.com> | 2009-05-21 16:01:58 +0000 |
|---|---|---|
| committer | Chris McDonough <chrism@agendaless.com> | 2009-05-21 16:01:58 +0000 |
| commit | 5a11e2ad0828b7c763d0c81211f686a85bc0324c (patch) | |
| tree | 750deaa5086279a1cd0baa28c0d5bdaa17414463 /repoze/bfg/tests/test_integration.py | |
| parent | 385084582eeff5f2f1a93f3b90c091dc1a4ad50e (diff) | |
| download | pyramid-5a11e2ad0828b7c763d0c81211f686a85bc0324c.tar.gz pyramid-5a11e2ad0828b7c763d0c81211f686a85bc0324c.tar.bz2 pyramid-5a11e2ad0828b7c763d0c81211f686a85bc0324c.zip | |
- Class objects may now be used as view callables (both via ZCML and
via use of the ``bfg_view`` decorator in Python 2.6 as a class
decorator). The calling semantics when using a class as a view
callable is similar to that of using a class as a Zope "browser
view": the class' ``__init__`` must accept two positional parameters
(conventionally named ``context``, and ``request``). The resulting
instance must be callable (it must have a ``__call__`` method).
When called, the instance should return a response. For example::
from webob import Response
class MyView(object):
def __init__(self, context, request):
self.context = context
self.request = request
def __call__(self):
return Response('hello from %s!' % self.context)
See the "Views" chapter in the documentation and the
``repoze.bfg.view`` API documentation for more information.
Diffstat (limited to 'repoze/bfg/tests/test_integration.py')
| -rw-r--r-- | repoze/bfg/tests/test_integration.py | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/repoze/bfg/tests/test_integration.py b/repoze/bfg/tests/test_integration.py index 8c088fce0..fdb85b87e 100644 --- a/repoze/bfg/tests/test_integration.py +++ b/repoze/bfg/tests/test_integration.py @@ -1,4 +1,5 @@ import os +import sys import unittest from repoze.bfg.push import pushpage @@ -142,8 +143,8 @@ class TestGrokkedApp(unittest.TestCase): cleanUp() def test_it(self): + import inspect import repoze.bfg.tests.grokkedapp as package - from zope.configuration import config from zope.configuration import xmlconfig context = config.ConfigurationMachine() @@ -151,7 +152,14 @@ class TestGrokkedApp(unittest.TestCase): context.package = package xmlconfig.include(context, 'configure.zcml', package) actions = context.actions - self.failUnless(actions) + klassview = actions[-1] + self.assertEqual(klassview[0][2], 'grokked_klass') + self.assertEqual(klassview[2][1], package.grokked_klass) + self.failUnless(inspect.isfunction(package.grokked_klass)) + self.assertEqual(package.grokked_klass(None, None), None) + funcview = actions[-2] + self.assertEqual(funcview[0][2], '') + self.assertEqual(funcview[2][1], package.grokked) class DummyContext: pass |
