Ejemplo n.º 1
0
    def testBasicContext_unicode(self):
        # Tests so that AbsoluteURL handle unicode names as well
        request = TestRequest()
        root = Root()
        root.__name__ = u"\u0439"

        content = contained(TrivialContent(), root, name=u"\u0442")
        content = contained(TrivialContent(), content, name=u"\u0435")
        content = contained(TrivialContent(), content, name=u"\u0441")
        view = getMultiAdapter((content, request), name="absolute_url")
        self.assertEqual(str(view), "http://127.0.0.1/%D0%B9/%D1%82/%D0%B5/%D1%81")
        self.assertEqual(view(), "http://127.0.0.1/%D0%B9/%D1%82/%D0%B5/%D1%81")
        self.assertEqual(unicode(view), u"http://127.0.0.1/\u0439/\u0442/\u0435/\u0441")
        self.assertEqual(absoluteURL(content, request), "http://127.0.0.1/%D0%B9/%D1%82/%D0%B5/%D1%81")

        breadcrumbs = view.breadcrumbs()
        self.assertEqual(
            breadcrumbs,
            (
                {"name": "", "url": "http://127.0.0.1"},
                {"name": u"\u0439", "url": "http://127.0.0.1/%D0%B9"},
                {"name": u"\u0442", "url": "http://127.0.0.1/%D0%B9/%D1%82"},
                {"name": u"\u0435", "url": "http://127.0.0.1/%D0%B9/%D1%82/%D0%B5"},
                {"name": u"\u0441", "url": "http://127.0.0.1/%D0%B9/%D1%82/%D0%B5/%D1%81"},
            ),
        )
Ejemplo n.º 2
0
 def setUp(self):
     PlacelessSetup.setUp(self)
     # Build up a wrapper chain
     self.root =   C('root')
     self.folder = contained(C('folder'), self.root,   name='folder')
     self.item =   contained(C('item'),   self.folder, name='item')
     self.tr = Traverser(self.item)
Ejemplo n.º 3
0
    def testBasicContext_unicode(self):
        #Tests so that AbsoluteURL handle unicode names as well
        request = TestRequest()
        root = Root()
        root.__name__ = u'\u0439'

        content = contained(TrivialContent(), root, name=u'\u0442')
        content = contained(TrivialContent(), content, name=u'\u0435')
        content = contained(TrivialContent(), content, name=u'\u0441')
        view = getMultiAdapter((content, request), name='absolute_url')
        self.assertEqual(str(view),
                         'http://127.0.0.1/%D0%B9/%D1%82/%D0%B5/%D1%81')
        self.assertEqual(view(),
                         'http://127.0.0.1/%D0%B9/%D1%82/%D0%B5/%D1%81')
        self.assertEqual(unicode(view),
                         u'http://127.0.0.1/\u0439/\u0442/\u0435/\u0441')
        self.assertEqual(absoluteURL(content, request),
                         'http://127.0.0.1/%D0%B9/%D1%82/%D0%B5/%D1%81')

        breadcrumbs = view.breadcrumbs()
        self.assertEqual(breadcrumbs,
                         ({'name':  '', 'url': 'http://127.0.0.1'},
                          {'name': u'\u0439', 'url': 'http://127.0.0.1/%D0%B9'},
                          {'name': u'\u0442',
                           'url': 'http://127.0.0.1/%D0%B9/%D1%82'},
                          {'name': u'\u0435',
                           'url': 'http://127.0.0.1/%D0%B9/%D1%82/%D0%B5'},
                          {'name': u'\u0441',
                           'url':
                           'http://127.0.0.1/%D0%B9/%D1%82/%D0%B5/%D1%81'},
                          ))
Ejemplo n.º 4
0
    def setUp(self):
        PlacelessSetup.setUp(self)
        # Build up a wrapper chain
        root = C('root')
        directlyProvides(root, IRoot)
        folder = C('folder')
        item = C('item')

        self.root = root  # root is not usually wrapped
        self.folder = contained(folder, self.root, name='folder')
        self.item = contained(item, self.folder, name='item')
        self.unwrapped_item = item
        self.broken_chain_folder = contained(folder, None)
        self.broken_chain_item = contained(item,
                                           self.broken_chain_folder,
                                           name='item')
        root.folder = folder
        folder.item = item

        self.tr = Traverser(root)
        zope.component.provideAdapter(Traverser, (None, ), ITraverser)
        zope.component.provideAdapter(DefaultTraversable, (None, ),
                                      ITraversable)
        zope.component.provideAdapter(LocationPhysicallyLocatable, (None, ),
                                      ILocationInfo)
        zope.component.provideAdapter(RootPhysicallyLocatable, (IRoot, ),
                                      ILocationInfo)
Ejemplo n.º 5
0
    def setUp(self):
        PlacelessSetup.setUp(self)
        # Build up a wrapper chain
        root = C('root')
        directlyProvides(root, IRoot)
        folder = C('folder')
        item = C('item')

        self.root = root  # root is not usually wrapped
        self.folder = contained(folder, self.root,   name='folder')
        self.item =   contained(item,   self.folder, name='item')
        self.unwrapped_item = item
        self.broken_chain_folder = contained(folder, None)
        self.broken_chain_item = contained(item,
                                    self.broken_chain_folder,
                                    name='item'
                                    )
        root.folder = folder
        folder.item = item

        self.tr = Traverser(root)
        zope.component.provideAdapter(Traverser, (None,), ITraverser)
        zope.component.provideAdapter(DefaultTraversable, (None,), ITraversable)
        zope.component.provideAdapter(LocationPhysicallyLocatable, (None,),
                                      ILocationInfo)
        zope.component.provideAdapter(RootPhysicallyLocatable,
                                      (IRoot,), ILocationInfo)
Ejemplo n.º 6
0
 def setUp(self):
     PlacelessSetup.setUp(self)
     # Build up a wrapper chain
     self.root = C('root')
     self.folder = contained(C('folder'), self.root, name='folder')
     self.item = contained(C('item'), self.folder, name='item')
     self.tr = Traverser(self.item)
Ejemplo n.º 7
0
 def test_not_deletable(self):
     container = UnwritableContainer()
     container.a = 'spam'
     item = contained(UnwritableContainer(), container, name='a')
     request = TestRequest()
     delete = zope.app.http.delete.DELETE(item, request)
     self.assertRaises(MethodNotAllowed, delete.DELETE)
Ejemplo n.º 8
0
    def testZPTRendering(self):
        page = ZopachePageTemplate()
        page.setSource(
            u''
            '<html>'
            '<head><title tal:content="options/title">blah</title></head>'
            '<body>'
            '<a href="foo" tal:attributes="href request/URL/1">'
            '<span tal:replace="container/name">splat</span>'
            '</a></body></html>'
            )

        page = contained(page, Data(name='zope'))

        request = Data(URL={'1': 'http://foo.com/'},
                       debug=Data(showTAL=False, sourceAnnotations=False))
        out = page.render(request, title="Zope rules")
        out = ' '.join(out.split())

        self.assertEqual(
            out,
            '<html><head><title>Zope rules</title></head><body>'
            '<a href="http://foo.com/">'
            'zope'
            '</a></body></html>'
            )
Ejemplo n.º 9
0
 def test_not_deletable(self):
     container = UnwritableContainer()
     container.a = 'spam'
     item = contained(UnwritableContainer(), container, name='a')
     request = TestRequest()
     delete = zope.app.http.delete.DELETE(item, request)
     self.assertRaises(MethodNotAllowed, delete.DELETE)
Ejemplo n.º 10
0
    def test_template_context_wrapping(self):

        class AU(BrowserView):
            def __str__(self):
                name = self.context.__name__
                if name is None:
                    return 'None'
                return name

        defineChecker(AU, NamesChecker(['__str__']))

        from zope.traversing.namespace import view
        from zope.traversing.interfaces import ITraversable
        provideAdapter(view, (None,), ITraversable, name="view")
        provideAdapter(view, (None, None), ITraversable, name="view")
        provideAdapter(
            AU, (IZopachePageTemplate, TestRequest), Interface, name='name')

        page = ZopachePageTemplate()
        page.setSource(
            u'<p tal:replace="template/@@name" />'
            )
        page = contained(page, None, name='zpt')
        request = TestRequest()
        self.assertEquals(page.render(request), u'zpt')
    def test(self):
        zope.traversing.testing.setUp()

        root = Root()
        f1 = contained(C(), root, name='f1')
        f2 = contained(SiteManagerContainer(), f1, name='f2')
        f3 = contained(C(), f2, name='f3')
        
        adapter = ILocationInfo(f3)

        self.assertEqual(adapter.getPath(), '/f1/f2/f3')
        self.assertEqual(adapter.getName(), 'f3')
        self.assertEqual(adapter.getRoot(), root)
        self.assertEqual(adapter.getNearestSite(), root)

        f2.setSiteManager(LocalSiteManager(f2))
        self.assertEqual(adapter.getNearestSite(), f2)
Ejemplo n.º 12
0
    def testVirtualHostingWithVHElements(self):
        request = TestRequest()

        vh_root = TrivialContent()
        content = contained(vh_root, Root(), name='a')
        request._vh_root = content
        content = contained(TrivialContent(), content, name='b')
        content = contained(TrivialContent(), content, name='c')
        view = getMultiAdapter((content, request), name='absolute_url')
        self.assertEqual(str(view), 'http://127.0.0.1/b/c')

        breadcrumbs = view.breadcrumbs()
        self.assertEqual(breadcrumbs,
         ({'name':  '', 'url': 'http://127.0.0.1'},
          {'name': 'b', 'url': 'http://127.0.0.1/b'},
          {'name': 'c', 'url': 'http://127.0.0.1/b/c'},
          ))
Ejemplo n.º 13
0
    def test_request_protected(self):
        page = ZPTPage()
        page.setSource(u'<p tal:content="python: request.__dict__" />')

        page = contained(page, Data(name='zope'))

        request = Data(debug=Data(showTAL=False, sourceAnnotations=False))
        self.assertRaises(Forbidden, page.render, request)
Ejemplo n.º 14
0
    def test(self):
        zope.traversing.testing.setUp()

        root = Root()
        f1 = contained(C(), root, name='f1')
        f2 = contained(SiteManagerContainer(), f1, name='f2')
        f3 = contained(C(), f2, name='f3')

        adapter = ILocationInfo(f3)

        self.assertEqual(adapter.getPath(), '/f1/f2/f3')
        self.assertEqual(adapter.getName(), 'f3')
        self.assertEqual(adapter.getRoot(), root)
        self.assertEqual(adapter.getNearestSite(), root)

        f2.setSiteManager(LocalSiteManager(f2))
        self.assertEqual(adapter.getNearestSite(), f2)
Ejemplo n.º 15
0
    def setUp(self):
        PlacelessSetup.setUp(self)

        zope.component.provideAdapter(DefaultTraversable, (None,), ITraversable)
        zope.component.provideAdapter(LocationPhysicallyLocatable, (None,),
                                      ILocationInfo)
        zope.component.provideAdapter(RootPhysicallyLocatable,
                                      (IRoot,), ILocationInfo)

        self.root = root = C('root')
        directlyProvides(root, IRoot)
        self.folder = folder = contained(C('folder'), root, 'folder')
        self.item = item = contained(C('item'), folder, 'item')

        root.folder = folder
        folder.item = item

        self.tr = Traverser(ProxyFactory(root))
Ejemplo n.º 16
0
    def testBasicContext(self):
        request = TestRequest()

        content = contained(TrivialContent(), Root(), name='a')
        content = contained(TrivialContent(), content, name='b')
        content = contained(TrivialContent(), content, name='c')
        view = getMultiAdapter((content, request), name='absolute_url')
        self.assertEqual(str(view), 'http://127.0.0.1/a/b/c')
        self.assertEqual(absoluteURL(content, request),
                         'http://127.0.0.1/a/b/c')

        breadcrumbs = view.breadcrumbs()
        self.assertEqual(breadcrumbs,
                         ({'name':  '', 'url': 'http://127.0.0.1'},
                          {'name': 'a', 'url': 'http://127.0.0.1/a'},
                          {'name': 'b', 'url': 'http://127.0.0.1/a/b'},
                          {'name': 'c', 'url': 'http://127.0.0.1/a/b/c'},
                          ))
Ejemplo n.º 17
0
    def testRetainSkin(self):
        request = TestRequest()
        request._traversed_names = ('a', 'b')
        request._app_names = ('++skin++test', )

        content = contained(TrivialContent(), Root(), name='a')
        content = contained(TrivialContent(), content, name='b')
        content = contained(TrivialContent(), content, name='c')
        view = getMultiAdapter((content, request), name='absolute_url')
        base = 'http://127.0.0.1/++skin++test'
        self.assertEqual(str(view), base + '/a/b/c')

        breadcrumbs = view.breadcrumbs()
        self.assertEqual(breadcrumbs,
                         ({'name':  '', 'url': base + ''},
                          {'name': 'a', 'url': base + '/a'},
                          {'name': 'b', 'url': base + '/a/b'},
                          {'name': 'c', 'url': base + '/a/b/c'},
                          ))
Ejemplo n.º 18
0
    def test_request_protected(self):
        page = ZopachePageTemplate()
        page.setSource(
            u'<p tal:content="python: request.__dict__" />'
            )

        page = contained(page, Data(name='zope'))

        request = Data(debug=Data(showTAL=False, sourceAnnotations=False))
        self.assertRaises(Forbidden, page.render, request)
Ejemplo n.º 19
0
    def setUp(self):
        PlacelessSetup.setUp(self)

        zope.component.provideAdapter(DefaultTraversable, (None, ),
                                      ITraversable)
        zope.component.provideAdapter(LocationPhysicallyLocatable, (None, ),
                                      ILocationInfo)
        zope.component.provideAdapter(RootPhysicallyLocatable, (IRoot, ),
                                      ILocationInfo)

        self.root = root = C('root')
        directlyProvides(root, IRoot)
        self.folder = folder = contained(C('folder'), root, 'folder')
        self.item = item = contained(C('item'), folder, 'item')

        root.folder = folder
        folder.item = item

        self.tr = Traverser(ProxyFactory(root))
Ejemplo n.º 20
0
    def test(self):
        container = Container()
        container.a = 'spam'
        item = contained(Container(), container, name='a')

        request = TestRequest()
        delete = zope.app.http.delete.DELETE(item, request)
        self.assert_(hasattr(container, 'a'))
        self.assertEqual(delete.DELETE(), '')
        self.assert_(not hasattr(container, 'a'))
Ejemplo n.º 21
0
    def test(self):
        container = Container()
        container.a = 'spam'
        item = contained(Container(), container, name='a')

        request = TestRequest()
        delete = zope.app.http.delete.DELETE(item, request)
        self.assert_(hasattr(container, 'a'))
        self.assertEqual(delete.DELETE(), '')
        self.assert_(not hasattr(container, 'a'))
Ejemplo n.º 22
0
    def testBasicContext(self):
        request = TestRequest()

        content = contained(TrivialContent(), Root(), name="a")
        content = contained(TrivialContent(), content, name="b")
        content = contained(TrivialContent(), content, name="c")
        view = getMultiAdapter((content, request), name="absolute_url")
        self.assertEqual(str(view), "http://127.0.0.1/a/b/c")
        self.assertEqual(absoluteURL(content, request), "http://127.0.0.1/a/b/c")

        breadcrumbs = view.breadcrumbs()
        self.assertEqual(
            breadcrumbs,
            (
                {"name": "", "url": "http://127.0.0.1"},
                {"name": "a", "url": "http://127.0.0.1/a"},
                {"name": "b", "url": "http://127.0.0.1/a/b"},
                {"name": "c", "url": "http://127.0.0.1/a/b/c"},
            ),
        )
Ejemplo n.º 23
0
    def testVirtualHostingWithVHElements(self):
        request = TestRequest()

        vh_root = TrivialContent()
        content = contained(vh_root, Root(), name="a")
        request._vh_root = content
        content = contained(TrivialContent(), content, name="b")
        content = contained(TrivialContent(), content, name="c")
        view = getMultiAdapter((content, request), name="absolute_url")
        self.assertEqual(str(view), "http://127.0.0.1/b/c")

        breadcrumbs = view.breadcrumbs()
        self.assertEqual(
            breadcrumbs,
            (
                {"name": "", "url": "http://127.0.0.1"},
                {"name": "b", "url": "http://127.0.0.1/b"},
                {"name": "c", "url": "http://127.0.0.1/b/c"},
            ),
        )
Ejemplo n.º 24
0
    def testRetainSkin(self):
        request = TestRequest()
        request._traversed_names = ("a", "b")
        request._app_names = ("++skin++test",)

        content = contained(TrivialContent(), Root(), name="a")
        content = contained(TrivialContent(), content, name="b")
        content = contained(TrivialContent(), content, name="c")
        view = getMultiAdapter((content, request), name="absolute_url")
        base = "http://127.0.0.1/++skin++test"
        self.assertEqual(str(view), base + "/a/b/c")

        breadcrumbs = view.breadcrumbs()
        self.assertEqual(
            breadcrumbs,
            (
                {"name": "", "url": base + ""},
                {"name": "a", "url": base + "/a"},
                {"name": "b", "url": base + "/a/b"},
                {"name": "c", "url": base + "/a/b/c"},
            ),
        )
Ejemplo n.º 25
0
    def rate(self, id, value, user):
        """See interfaces.IRatingsManager"""
        defn = self._getDefinition(id)

        if not defn.scoreSystem.isValidScore(value):
            raise ValueError('Invalid rating value %r for %r.' % (value, id))

        if id not in self._storage:
            self._storage[id] = OOBTree.OOBTree()
            contained.contained(self._storage[id], self._storage, id)
        existing = self._storage[id].get(user)
        if existing is not None and existing.value == value:
            # do nothing if no change
            return False
        self._storage[id][user] = rating.Rating(id, value, user)
        if existing is None:
            zope.event.notify(
                interfaces.RatingAddedEvent(id, self.__parent__, user, value))
        else:
            zope.event.notify(
                interfaces.RatingChangedEvent(id, self.__parent__, user,
                                              value))
        return True
Ejemplo n.º 26
0
    def test_template_context_wrapping(self):
        class AU(BrowserView):
            def __str__(self):
                name = self.context.__name__
                if name is None:
                    return 'None'
                return name

        defineChecker(AU, NamesChecker(['__str__']))

        from zope.traversing.namespace import view
        ztapi.provideNamespaceHandler('view', view)
        ztapi.browserView(IZPTPage, 'name', AU)

        page = ZPTPage()
        page.setSource(u'<p tal:replace="template/@@name" />')
        page = contained(page, None, name='zpt')
        request = TestRequest()
        self.assertEquals(page.render(request), u'zpt')
Ejemplo n.º 27
0
    def testTemplateRendering(self):
        class Template(object):
            def render(self, request, **kw):
                self.called = request, kw
                return 42

            content_type = 'text/x-test'

        class Folder(object):
            name = 'zope'

        folder = Folder()

        class Response(object):

            base = None

            def setBase(self, base):
                self.base = base

            def setHeader(self, name, value):
                setattr(self, name, value)

        class Request(object):

            response = Response()

            URL = ['http://localhost', 'http://localhost/pt']

        request = Request()
        template = contained(Template(), folder)

        view = ZPTPageEval()
        # Do manually, since directive adds BrowserView as base class
        view.context = template
        view.request = request
        self.assertEqual(view.index(), 42)
        self.assertEqual(template.called, (request, {}))
        self.assertEqual(getattr(request.response, 'content-type'),
                         'text/x-test')
Ejemplo n.º 28
0
 def _lookup_or_create_storage(self):
     category = self.category
     context = self.context
     # lookup the key directly on the category if set (this used for BBB)
     if hasattr(category, 'key'):
         key = category.key
     else:
         # Get the key from the storage, or use a default
         key = getattr(category.storage, 'annotation_key', BASE_KEY)
         # Append the category name to the dotted annotation key name
         if category.name:
             key = str(key + '.' + category.name)
     # Retrieve the storage from the annotation, or create a new one
     annotations = IAnnotations(context)
     try:
         storage = annotations[key]
         if storage is None:
             storage = annotations[key] = category.storage()
     except KeyError:
         storage = annotations[key] = category.storage()
         # set containment for the ratings storage
     if not isinstance(storage, category.storage):
         # if the storage is not an instance of the category
         # storage, attempt to migrate it.  This check
         # requires that storage factories be implemented
         # as standard class.
         orig_storage = storage
         storage = category.storage()
         migrator = getMultiAdapter((orig_storage, storage),
                                    IRatingStorageMigrator)
         storage = migrator.migrate()
         # the migrator may have returned a different object
         # or it may have accepted the original storage
         if annotations[key] is not storage:
             annotations[key] = storage
     # Use the unwrapped context as container, so that
     # this doesn't mutate the storage everytime when
     # context changes due to wrapping.  This should
     # only have an effect when the storage is new.
     return contained(storage, aq_base(context), key)
Ejemplo n.º 29
0
    def testTemplateRendering(self):

        class Template(object):
            def render(self, request, **kw):
                self.called = request, kw
                return 42

            content_type = 'text/x-test'

        class Folder(object):
            name='zope'
        folder = Folder()

        class Response(object):

            base = None

            def setBase(self, base):
                self.base = base

            def setHeader(self, name, value):
                setattr(self, name, value)

        class Request(object):

            response = Response()

            URL = ['http://localhost', 'http://localhost/pt']

        request = Request()
        template = contained(Template(), folder)

        view = ZopachePageTemplateEval()
        # Do manually, since directive adds BrowserView as base class
        view.context = template
        view.request = request
        self.assertEqual(view.index(), 42)
        self.assertEqual(template.called, (request, {}))
        self.assertEqual(getattr(request.response, 'content-type'),
                         'text/x-test')
Ejemplo n.º 30
0
 def _lookup_or_create_storage(self):
     category = self.category
     context = self.context
     # lookup the key directly on the category if set (this used for BBB)
     if hasattr(category, 'key'):
         key = category.key
     else:
         # Get the key from the storage, or use a default
         key = getattr(category.storage, 'annotation_key', BASE_KEY)
         # Append the category name to the dotted annotation key name
         if category.name:
             key = str(key + '.' + category.name)
     # Retrieve the storage from the annotation, or create a new one
     annotations = IAnnotations(context)
     try:
         storage = annotations[key]
         if storage is None:
             storage = annotations[key] = category.storage()
     except KeyError:
         storage = annotations[key] = category.storage()
         # set containment for the ratings storage
     if not isinstance(storage, category.storage):
         # if the storage is not an instance of the category
         # storage, attempt to migrate it.  This check
         # requires that storage factories be implemented
         # as standard class.
         orig_storage = storage
         storage = category.storage()
         migrator = getMultiAdapter((orig_storage, storage),
                                    IRatingStorageMigrator)
         storage = migrator.migrate()
         # the migrator may have returned a different object
         # or it may have accepted the original storage
         if annotations[key] is not storage:
             annotations[key] = storage
     # Use the unwrapped context as container, so that
     # this doesn't mutate the storage everytime when
     # context changes due to wrapping.  This should
     # only have an effect when the storage is new.
     return contained(storage, aq_base(context), key)
Ejemplo n.º 31
0
    def testZPTRendering(self):
        page = ZPTPage()
        page.setSource(
            u''
            '<html>'
            '<head><title tal:content="options/title">blah</title></head>'
            '<body>'
            '<a href="foo" tal:attributes="href request/URL/1">'
            '<span tal:replace="container/name">splat</span>'
            '</a></body></html>')

        page = contained(page, Data(name='zope'))

        request = Data(URL={'1': 'http://foo.com/'},
                       debug=Data(showTAL=False, sourceAnnotations=False))
        out = page.render(request, title="Zope rules")
        out = ' '.join(out.split())

        self.assertEqual(
            out, '<html><head><title>Zope rules</title></head><body>'
            '<a href="http://foo.com/">'
            'zope'
            '</a></body></html>')
Ejemplo n.º 32
0
    def test_interface(self):
        request = TestRequest()
        content = contained(TrivialContent(), Root(), name="a")
        view = getMultiAdapter((content, request), name="absolute_url")

        verifyObject(IAbsoluteURL, view)
Ejemplo n.º 33
0
 def __parent__(self):
     return contained(TrivialContent(), Root(), name="bar")
Ejemplo n.º 34
0
 def testVirtualHostingWithoutContextInformation(self):
     request = TestRequest()
     request._vh_root = contained(TrivialContent(), Root(), name="a")
     view = getMultiAdapter((None, request), name="absolute_url")
     self.assertEqual(str(view), "http://127.0.0.1")
     self.assertEqual(absoluteURL(None, request), "http://127.0.0.1")
 def _TestView__newContext(self):
     from zope.app.container.sample import SampleContainer
     from zope.site.folder import rootFolder
     root = rootFolder()
     container = SampleContainer()
     return contained(container, root, 'sample')
Ejemplo n.º 36
0
 def testVirtualHostingWithoutContextInformation(self):
     request = TestRequest()
     request._vh_root = contained(TrivialContent(), Root(), name='a')
     view = getMultiAdapter((None, request), name='absolute_url')
     self.assertEqual(str(view), 'http://127.0.0.1')
     self.assertEqual(absoluteURL(None, request), 'http://127.0.0.1')
Ejemplo n.º 37
0
 def pageInContext(self, page):
     root = Data()
     directlyProvides(root, IContainmentRoot)
     folder = contained(Data(), root, name='folder')
     return contained(page, folder, name='zpt')
Ejemplo n.º 38
0
 def __parent__(self):
     return contained(TrivialContent(), Root(), name='bar')
Ejemplo n.º 39
0
 def pageInContext(self, page):
     root = Data()
     directlyProvides(root, IContainmentRoot)
     folder = contained(Data(), root, name='folder')
     return contained(page, folder, name='zpt')
Ejemplo n.º 40
0
 def test_contained(self):
     obj = contained(self, 42, 'name')
     self.assertEqual(obj, self)
     self.assertEqual(obj.__name__, 'name')
     self.assertEqual(obj.__parent__, 42)
Ejemplo n.º 41
0
    def test_interface(self):
        request = TestRequest()
        content = contained(TrivialContent(), Root(), name='a')
        view = getMultiAdapter((content, request), name='absolute_url')

        verifyObject(IAbsoluteURL, view)