def testDefaultViewWithLayer(self): class FakeRequest(TestRequest): implements(ITestLayer) request2 = FakeRequest() self.assertEqual( zapi.queryMultiAdapter((ob, request2), IDefaultViewName), None) xmlconfig(StringIO(template % ( ''' <browser:defaultView name="test" for="zope.app.component.tests.views.IC" /> <browser:defaultView name="test2" for="zope.app.component.tests.views.IC" layer=" zope.app.publisher.browser.tests.test_directives.ITestLayer" /> ''' ))) self.assertEqual(zapi.getDefaultViewName(ob, request2), 'test2') self.assertEqual(zapi.getDefaultViewName(ob, request), 'test')
def defaultView(self, request): context = self.context try: name = getDefaultViewName(context, request) return context, [name,] except ComponentLookupError: return context, None
def browserDefault(self, request): ob = self.context if providedBy(ob): view_name = zapi.getDefaultViewName(ob, request) return ob, (("@@%s" % view_name),) return ob, ()
def testDefaultView(self): self.assertEqual( zapi.queryMultiAdapter((ob, request), IDefaultViewName), None) xmlconfig(StringIO(template % ( ''' <browser:defaultView name="test" for="zope.app.component.tests.views.IC" /> ''' ))) self.assertEqual(zapi.getDefaultViewName(ob, request), 'test')
def browserDefault(self, request): ob = self.context view_name = zapi.getDefaultViewName(ob, request) view = self.publishTraverse(request, view_name) if hasattr(view, 'browserDefault'): view, path = view.browserDefault(request) if len(path) == 1: view = view.publishTraverse(request, path[0]) path = () else: path = () return view, path
def browserDefault(self, request): ob = self.context view_name = zapi.getDefaultViewName(ob, request) return ob, (view_name,)
def browserDefault(self, request): """See zope.publisher.browser.interfaces.IBrowserPublisher""" view_name = zapi.getDefaultViewName(self.context, request) view_uri = "@@%s" % view_name return self.context, (view_uri,)
def browserDefault(self, request): c = self.context view_name = zapi.getDefaultViewName(c, request) view_uri = "@@%s" % view_name return c, (view_uri,)