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))
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))
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
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