Пример #1
0
    def test_getData_sets_request_layers(self):
        book = create(Builder("book").with_layout(IDefaultBookLayoutSelectionLayer))

        self.remove_request_interfaces()
        self.assertFalse(IDefaultBookLayoutSelectionLayer.providedBy(self.request))
        self.assertFalse(IWithinBookLayer.providedBy(self.request))
        collector = getAdapter(book, IDataCollector, name="010-book-layout-request-layers")
        collector.getData()
        self.assertTrue(IDefaultBookLayoutSelectionLayer.providedBy(self.request))
        self.assertTrue(IWithinBookLayer.providedBy(self.request))
Пример #2
0
    def test_getData_sets_request_layers(self):
        book = create(
            Builder('book').with_layout(IDefaultBookLayoutSelectionLayer))

        self.remove_request_interfaces()
        self.assertFalse(
            IDefaultBookLayoutSelectionLayer.providedBy(self.request))
        self.assertFalse(IWithinBookLayer.providedBy(self.request))
        collector = getAdapter(book,
                               IDataCollector,
                               name='010-book-layout-request-layers')
        collector.getData()
        self.assertTrue(
            IDefaultBookLayoutSelectionLayer.providedBy(self.request))
        self.assertTrue(IWithinBookLayer.providedBy(self.request))
Пример #3
0
    def _context_is_within_book(self):
        # In some cases REQUEST is no available.
        if not hasattr(self.context, 'REQUEST'):
            return False

        if IWithinBookLayer.providedBy(self.context.REQUEST):
            return True
        return False
Пример #4
0
    def _context_is_within_book(self):

        # In some cases REQUEST is no available.
        # XXX: This is a quick fix without debugging, just a guess
        if not hasattr(self.context, 'REQUEST'):
            return False

        if IWithinBookLayer.providedBy(self.context.REQUEST):
            return True
        return False