[Zope3-checkins] CVS: Zope3/src/zope/app/tests - ztapi.py:1.2
Jim Fulton
cvs-admin at zope.org
Fri Nov 21 12:09:38 EST 2003
Update of /cvs-repository/Zope3/src/zope/app/tests
In directory cvs.zope.org:/tmp/cvs-serv29718/src/zope/app/tests
Added Files:
ztapi.py
Log Message:
Began adding a new standard api for testing.
=== Zope3/src/zope/app/tests/ztapi.py 1.1 => 1.2 ===
--- /dev/null Fri Nov 21 12:09:38 2003
+++ Zope3/src/zope/app/tests/ztapi.py Fri Nov 21 12:09:37 2003
@@ -0,0 +1,46 @@
+##############################################################################
+#
+# Copyright (c) 2003 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""Testing helper functions
+
+$Id$
+"""
+from zope.app import zapi
+import zope.interface
+from zope.component.servicenames import Presentation, Adapters
+from zope.publisher.browser import IBrowserRequest
+
+def browserView(for_, name, factory, layer='default'):
+ """Define a global browser view
+ """
+ s = zapi.getService(None, Presentation)
+ return s.provideView(for_, name, IBrowserRequest, factory, layer)
+
+def browserResource(name, factory, layer='default'):
+ """Define a global browser view
+ """
+ s = zapi.getService(None, Presentation)
+ return s.provideResource(name, IBrowserRequest, factory, layer)
+
+
+def setDefaultViewName(for_, name, layer='default'):
+ s = zapi.getService(None, Presentation)
+ s.setDefaultViewName(for_, IBrowserRequest, name, layer=layer)
+
+stypes = list, tuple
+def provideAdapter(required, provided, factory, name='', with=()):
+ s = zapi.getService(None, Adapters)
+ if not isinstance(factory, stypes):
+ factory = [factory]
+ s.provideAdapter(required, provided, factory, name, with)
+
More information about the Zope3-Checkins
mailing list