[Zope3-checkins]
SVN: Zope3/branches/roger-contentprovider/src/zope/contentprovider/README.txt
Error handling is working.
Stephan Richter
srichter at cosmos.phy.tufts.edu
Sat Oct 8 06:55:04 EDT 2005
Log message for revision 38934:
Error handling is working.
Changed:
U Zope3/branches/roger-contentprovider/src/zope/contentprovider/README.txt
-=-
Modified: Zope3/branches/roger-contentprovider/src/zope/contentprovider/README.txt
===================================================================
--- Zope3/branches/roger-contentprovider/src/zope/contentprovider/README.txt 2005-10-08 10:39:48 UTC (rev 38933)
+++ Zope3/branches/roger-contentprovider/src/zope/contentprovider/README.txt 2005-10-08 10:55:04 UTC (rev 38934)
@@ -137,10 +137,44 @@
Failure to lookup a Content Provider
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+If the name is not found, an error is raied. To demonstrate this behavior
+let's create another template:
+ >>> errorFileName = os.path.join(temp_dir, 'template.pt')
+ >>> open(errorFileName, 'w').write('''
+ ... <html>
+ ... <body>
+ ... <tal:block replace="structure provider:mypage.UnknownName" />
+ ... </body>
+ ... </html>
+ ... ''')
+
+ >>> ErrorPage = SimpleViewClass(errorFileName, name='error.html')
+ >>> zope.component.provideAdapter(
+ ... ErrorPage,
+ ... (zope.interface.Interface, browser.IDefaultBrowserLayer),
+ ... zope.interface.Interface,
+ ... name='main.html')
+
+ >>> view = zope.component.getMultiAdapter((content, request),
+ ... name='main.html')
+ >>> print view().strip()
+ Traceback (most recent call last):
+ ...
+ ContentProviderLookupError: u'mypage.UnknownName'
+
+
Additional Data from TAL
~~~~~~~~~~~~~~~~~~~~~~~~
You might also want to look at the ``zope.viewlet`` package for a more
-featureful API.
\ No newline at end of file
+featureful API.
+
+
+Cleanup
+-------
+
+ >>> import shutil
+ >>> shutil.rmtree(temp_dir)
+
More information about the Zope3-Checkins
mailing list