[Zope3-checkins] SVN: Zope3/branches/roger-contentprovider/src/zope/portlet/ Added portlet namespace

Roger Ineichen roger at projekt01.ch
Sat Oct 8 11:47:03 EDT 2005


Log message for revision 38961:
  Added portlet namespace

Changed:
  A   Zope3/branches/roger-contentprovider/src/zope/portlet/configure.zcml
  A   Zope3/branches/roger-contentprovider/src/zope/portlet/namespace.py
  U   Zope3/branches/roger-contentprovider/src/zope/portlet/tests/test_doc.py
  A   Zope3/branches/roger-contentprovider/src/zope/portlet/zope.portlet-configure.zcml
  U   Zope3/branches/roger-contentprovider/src/zope/portlet/zope.portlet-meta.zcml

-=-
Added: Zope3/branches/roger-contentprovider/src/zope/portlet/configure.zcml
===================================================================
--- Zope3/branches/roger-contentprovider/src/zope/portlet/configure.zcml	2005-10-08 15:20:12 UTC (rev 38960)
+++ Zope3/branches/roger-contentprovider/src/zope/portlet/configure.zcml	2005-10-08 15:47:03 UTC (rev 38961)
@@ -0,0 +1,16 @@
+<configure 
+    xmlns="http://namespaces.zope.org/zope"
+    i18n_domain="tiks">
+
+  <!-- ++view++ namespace is used as a hook for IControllable objects -->
+  <view
+      name="portlet"
+      type="*"
+      for="*"
+      provides="zope.app.traversing.interfaces.ITraversable"
+      factory=".namespace.portlet"
+      />
+
+  <include package=".browser" />
+
+</configure>
\ No newline at end of file


Property changes on: Zope3/branches/roger-contentprovider/src/zope/portlet/configure.zcml
___________________________________________________________________
Name: svn:eol-style
   + native

Added: Zope3/branches/roger-contentprovider/src/zope/portlet/namespace.py
===================================================================
--- Zope3/branches/roger-contentprovider/src/zope/portlet/namespace.py	2005-10-08 15:20:12 UTC (rev 38960)
+++ Zope3/branches/roger-contentprovider/src/zope/portlet/namespace.py	2005-10-08 15:47:03 UTC (rev 38961)
@@ -0,0 +1,107 @@
+##############################################################################
+#
+# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (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.
+#
+##############################################################################
+"""Portlet namespace implementation
+
+$Id$
+"""
+__docformat__ = 'restructuredtext'
+
+from zope.component import getMultiAdapter
+from zope.interface import implements
+
+from zope.app.traversing.interfaces import ITraversable
+from zope.app.traversing.interfaces import TraversalError
+from zope.app.zapi import getPath
+
+from zope.portlet.interfaces import IPortletManager
+
+
+
+class portlet(object):
+    """
+    Placeless setup:
+
+        >>> import zope.component
+        >>> from zope.app.testing import placelesssetup, ztapi
+        >>> from zope.app.testing import setup
+        >>> placelesssetup.setUp()
+        >>> setup.setUpTraversal()
+        
+    Setup a view for test the traversable ``++portlet++`` namesapce:
+
+        >>> from zope.publisher.browser import TestRequest
+        >>> from zope.app.publisher.browser import BrowserView
+        >>> from zope.interface import Interface
+      
+        >>> class TestContext(object):
+        ...     implements(Interface)
+
+    Setup the view on the context:
+
+        >>> testRequest = TestRequest()
+        >>> testContext = TestContext()
+
+    Setup a view:
+
+        >>> from zope.portlet.interfaces import IPortlet
+        >>> class MyView(BrowserView):
+        ...     implements(IPortlet)
+        ...
+        >>> view = MyView(testContext, testRequest)
+
+    Setup PortletManager::
+
+        >>> from zope.portlet.interfaces import IPortletManager
+        >>> class DummyPortletManager(object):
+        ...     implements(IPortletManager)
+        ...     def __init__(self, context, request, view):
+        ...         pass
+
+    Try to traverse ``++portlet++`` namespace on te view the view:
+
+        >>> from zope.publisher.browser import IBrowserRequest
+        >>> from zope.app.testing.ztapi import provideAdapter
+        >>> provideAdapter(Interface, IPortletManager, DummyPortletManager, name='foo', with=(IBrowserRequest, IPortlet))
+
+    Test setup:
+
+        >>> Interface.providedBy(testContext)
+        True
+        >>> IBrowserRequest.providedBy(testRequest)
+        True
+        >>> IPortlet.providedBy(view)
+        True
+
+    Test namespace:
+
+        >>> traverser = portlet(view, testRequest)
+        >>> portletManager = traverser.traverse('foo', None)
+        >>> IPortletManager.providedBy(portletManager)
+        True
+
+        >>> placelesssetup.tearDown()
+    """
+
+    implements(ITraversable)
+
+    def __init__(self, context, request):
+        self.context = context.context
+        self.request = request
+        self.view = context
+
+    def traverse(self, name, ignored):
+        """Get portlet manager or portlet."""
+
+        objs = (self.context, self.request, self.view)
+        return getMultiAdapter(objs, IPortletManager, name=name)


Property changes on: Zope3/branches/roger-contentprovider/src/zope/portlet/namespace.py
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native

Modified: Zope3/branches/roger-contentprovider/src/zope/portlet/tests/test_doc.py
===================================================================
--- Zope3/branches/roger-contentprovider/src/zope/portlet/tests/test_doc.py	2005-10-08 15:20:12 UTC (rev 38960)
+++ Zope3/branches/roger-contentprovider/src/zope/portlet/tests/test_doc.py	2005-10-08 15:47:03 UTC (rev 38961)
@@ -24,26 +24,26 @@
 from zope.testing.doctestunit import DocTestSuite, DocFileSuite
 from zope.app.testing import setup
 
-from zope.contentprovider.interfaces import IRegion
+#from zope.contentprovider.interfaces import IRegion
 
 
-class TestPortlet(object):
+#class TestPortlet(object):
+#
+#    def doSomething(self):
+#        return u'something'
+#
+#
+#class TestPortlet2(object):
+#
+#    def __call__(self):
+#        return u'called'
+#
+#
+#class ITestRegion(zope.interface.Interface):
+#    """A region for testing purposes."""
+#zope.interface.directlyProvides(ITestRegion, IRegion)
 
-    def doSomething(self):
-        return u'something'
 
-
-class TestPortlet2(object):
-
-    def __call__(self):
-        return u'called'
-
-
-class ITestRegion(zope.interface.Interface):
-    """A region for testing purposes."""
-zope.interface.directlyProvides(ITestRegion, IRegion)
-
-
 class TestParticipation(object):
     principal = 'foobar'
     interaction = None
@@ -65,14 +65,15 @@
 
 def test_suite():
     return unittest.TestSuite((
-        DocFileSuite('../README.txt',
-                     setUp=setUp, tearDown=tearDown,
-                     optionflags=doctest.NORMALIZE_WHITESPACE|doctest.ELLIPSIS,
-                     ),
-         DocFileSuite('../directives.txt',
-                      setUp=setUp, tearDown=tearDown,
-                      optionflags=doctest.NORMALIZE_WHITESPACE|doctest.ELLIPSIS,
-                      ),
+        DocTestSuite('zope.portlet.namespace'),
+#        DocFileSuite('../README.txt',
+#                     setUp=setUp, tearDown=tearDown,
+#                     optionflags=doctest.NORMALIZE_WHITESPACE|doctest.ELLIPSIS,
+#                     ),
+#         DocFileSuite('../directives.txt',
+#                      setUp=setUp, tearDown=tearDown,
+#                      optionflags=doctest.NORMALIZE_WHITESPACE|doctest.ELLIPSIS,
+#                      ),
         ))
 
 if __name__ == '__main__':

Added: Zope3/branches/roger-contentprovider/src/zope/portlet/zope.portlet-configure.zcml
===================================================================
--- Zope3/branches/roger-contentprovider/src/zope/portlet/zope.portlet-configure.zcml	2005-10-08 15:20:12 UTC (rev 38960)
+++ Zope3/branches/roger-contentprovider/src/zope/portlet/zope.portlet-configure.zcml	2005-10-08 15:47:03 UTC (rev 38961)
@@ -0,0 +1 @@
+<include package="zope.portlet" />


Property changes on: Zope3/branches/roger-contentprovider/src/zope/portlet/zope.portlet-configure.zcml
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: Zope3/branches/roger-contentprovider/src/zope/portlet/zope.portlet-meta.zcml
===================================================================
--- Zope3/branches/roger-contentprovider/src/zope/portlet/zope.portlet-meta.zcml	2005-10-08 15:20:12 UTC (rev 38960)
+++ Zope3/branches/roger-contentprovider/src/zope/portlet/zope.portlet-meta.zcml	2005-10-08 15:47:03 UTC (rev 38961)
@@ -1 +1 @@
-<include package="zope.viewlet" file="meta.zcml" />
+<include package="zope.portlet" file="meta.zcml" />



More information about the Zope3-Checkins mailing list