def test_localsite_on_root(self): # ISiteManager is an adapter on publication to manage local sites. manager = ISiteManager(self.root) self.assertTrue(verifyObject(ISiteManager, manager)) # By default the root is a local site self.assertTrue(manager.is_site()) # And you can't disable it/play with it self.assertRaises(ValueError, manager.delete_site) self.assertRaises(ValueError, manager.make_site)
def test_localsite_on_publication(self): # Now we add a publication factory = self.root.manage_addProduct["Silva"] factory.manage_addPublication("publication", "publication") # We can get an adapter on it. manager = ISiteManager(self.root.publication) self.assertTrue(verifyObject(ISiteManager, manager)) # It's not a local site by default. self.assertFalse(manager.is_site()) # So we can't disable it. self.assertRaises(ValueError, manager.delete_site) # But we can enable it. manager.make_site() self.assertTrue(manager.is_site()) # Only one time self.assertRaises(ValueError, manager.make_site) # We can add a local service in it. factory = self.root.publication.manage_addProduct["silva.core.layout"] factory.manage_addCustomizationService("service_customization") self.assertTrue(hasattr(self.root.publication, "service_customization")) # We need to delete our service first self.root.publication.manage_delObjects(["service_customization"]) # And disable it. manager.delete_site() self.assertFalse(manager.is_site()) self.assertRaises(ValueError, manager.delete_site)
def setUp(self): """Test content structure: root/service_files (by default) root/folder root/folder/publication root/folder/publication/folder1in1in1 root/folder/publication/service_files root/folder2 """ self.root = self.layer.get_application() self.layer.login('manager') factory = self.root.manage_addProduct['Silva'] factory.manage_addFolder('folder', 'Folder') factory.manage_addFolder('contact', 'Contact Folder') factory = self.root.folder.manage_addProduct['Silva'] factory.manage_addPublication('publication', 'Publication') factory = self.root.folder.publication.manage_addProduct['Silva'] factory.manage_addFolder('folder1in1in1', 'Folder 1 in 1 in 1') # We can only add a new service in a site ISiteManager(self.root.folder.publication).make_site() factory.manage_addFilesService()
def manage_options(self): base_options = super(Publication, self).manage_options manage_options = (base_options[0], ) if ISiteManager(self).is_site(): manage_options += ({ 'label': 'Services', 'action': 'manage_services' }, ) return manage_options + base_options[1:]