[Checkins] SVN: zc.publication/branches/dev/s Got basic tests working. Yay!
Jim Fulton
jim at zope.com
Sun Jun 21 10:45:23 EDT 2009
Log message for revision 101197:
Got basic tests working. Yay!
Changed:
U zc.publication/branches/dev/setup.py
U zc.publication/branches/dev/src/zc/publication/README.txt
U zc.publication/branches/dev/src/zc/publication/__init__.py
U zc.publication/branches/dev/src/zc/publication/tests.py
-=-
Modified: zc.publication/branches/dev/setup.py
===================================================================
--- zc.publication/branches/dev/setup.py 2009-06-21 14:23:55 UTC (rev 101196)
+++ zc.publication/branches/dev/setup.py 2009-06-21 14:45:23 UTC (rev 101197)
@@ -17,7 +17,7 @@
'ZConfig',
'setuptools',
'zope.app.component',
- 'zope.app.publication',
+ 'zope.app.publication >=3.8.1',
'zope.app.publisher',
'zope.authentication',
'zope.component [zcml]',
Modified: zc.publication/branches/dev/src/zc/publication/README.txt
===================================================================
--- zc.publication/branches/dev/src/zc/publication/README.txt 2009-06-21 14:23:55 UTC (rev 101196)
+++ zc.publication/branches/dev/src/zc/publication/README.txt 2009-06-21 14:45:23 UTC (rev 101197)
@@ -35,9 +35,7 @@
.. -> src
- >>> import sys
- >>> sys.path.insert(0, '.')
- >>> open('hello.py', 'w').write(src)
+ >>> update_module('hello', src)
To turn this into a web application, we'll use ``zc.publication``.
``zc.publication`` builds on ``zope.publisher`` and Paste Deployment.
@@ -137,8 +135,7 @@
.. -> src
- >>> open('hello.py', 'w').write(src)
- >>> del sys.modules['hello']
+ >>> update_module('hello', src)
A view adapts a context, typically a content object of some sort, and
a request and provides a call method to generate a page.
@@ -182,14 +179,7 @@
.. -> url strio
- >>> import logging
- >>> logger = logging.getLogger()
- >>> logger.setLevel(logging.INFO)
- >>> logger.addHandler(logging.StreamHandler(sys.stdout))
-
- >>> app.get(url, status=500).body
-
- >>> app.get(url, status=200).body.strip() == expected
+ >>> app.get(url, status=200).body.strip().split() == expected.split()
True
or::
@@ -198,7 +188,7 @@
.. -> url strip
- >>> app.get(url, status=200).body.strip() == expected
+ >>> app.get(url, status=200).body.strip().split() == expected.split()
True
@@ -368,9 +358,3 @@
matching is a reasonable approach to traversal, however, traversal
is a useful approach in many applications, especially application
with data-driven URL hierarchies.
-
-
-.. cleanup
-
- >>> _ = sys.path.pop(0)
- >>> del sys.modules['hello']
Modified: zc.publication/branches/dev/src/zc/publication/__init__.py
===================================================================
--- zc.publication/branches/dev/src/zc/publication/__init__.py 2009-06-21 14:23:55 UTC (rev 101196)
+++ zc.publication/branches/dev/src/zc/publication/__init__.py 2009-06-21 14:45:23 UTC (rev 101197)
@@ -58,34 +58,9 @@
import logging
logging.basicConfig()
- # XXX zope.app.publication should have an overridable proxy method
-
def proxy(self, ob):
return ob
- # XXX the following method is overridden to use
- # self.proxy rather than ProxyFactory:
-
- def getDefaultTraversal(self, request, ob):
- if zope.publisher.interfaces.browser.IBrowserPublisher.providedBy(ob):
- # ob is already proxied, so the result of calling a method will be
- return ob.browserDefault(request)
- else:
- adapter = zope.component.queryMultiAdapter(
- (ob, request),
- zope.publisher.interfaces.browser.IBrowserPublisher,
- )
- if adapter is not None:
- ob, path = adapter.browserDefault(request)
- return self.proxy(ob), path
- else:
- # ob is already proxied
- return ob, None
-
- # XXX we should override handleException too, but it's rather complicated.
- # *really* should release a new version of zope.app.publication.
-
-
class Application(zope.publisher.paste.Application):
def __init__(self, global_config=None, **options):
Modified: zc.publication/branches/dev/src/zc/publication/tests.py
===================================================================
--- zc.publication/branches/dev/src/zc/publication/tests.py 2009-06-21 14:23:55 UTC (rev 101196)
+++ zc.publication/branches/dev/src/zc/publication/tests.py 2009-06-21 14:45:23 UTC (rev 101197)
@@ -19,7 +19,9 @@
import os
import paste.deploy
import re
+import sys
import textwrap
+import types
import unittest
import webtest
@@ -55,6 +57,15 @@
setupstack.setUpDirectory(test)
test.globs['testapp'] = testapp
+ def update_module(name, src):
+ if name not in sys.modules:
+ sys.modules[name] = types.ModuleType(name)
+ setupstack.register(test, sys.modules.__delitem__, name)
+ module = sys.modules[name]
+ exec src in module.__dict__
+
+ test.globs['update_module'] = update_module
+
def test_suite():
return unittest.TestSuite((
manuel.testing.TestSuite(
More information about the Checkins
mailing list