Example #1
0
    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')
Example #2
0
 def defaultView(self, request):
     context = self.context
     try:
         name = getDefaultViewName(context, request)
         return context, [name,]
     except ComponentLookupError:
         return context, None
Example #3
0
 def defaultView(self, request):
     context = self.context
     try:
         name = getDefaultViewName(context, request)
         return context, [name,]
     except ComponentLookupError:
         return context, None
Example #4
0
    def browserDefault(self, request):
        ob = self.context

        if providedBy(ob):
            view_name = zapi.getDefaultViewName(ob, request)
            return ob, (("@@%s" % view_name),)

        return ob, ()
Example #5
0
    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')
Example #6
0
    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
Example #7
0
 def browserDefault(self, request):
     ob = self.context
     view_name = zapi.getDefaultViewName(ob, request)
     return ob, (view_name,)
Example #8
0
 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,)
Example #9
0
 def browserDefault(self, request):
     c = self.context
     view_name = zapi.getDefaultViewName(c, request)
     view_uri = "@@%s" % view_name
     return c, (view_uri,)