def jsonSCEmbedderFolderListing(self, rooted, document_base_url): """Returns the folderlisting of sc.embedder objects in JSON""" utility = getUtility(ITinyMCE) portal_types = ["sc.embedder"] portal_types.extend(utility.containsobjects.split("\n")) object = IJSONFolderListing(self.context, None) if object is None: return "" results = object.getListing(portal_types, rooted, document_base_url) return results
def jsonLinkableFolderListing(self, rooted, document_base_url): """Returns the folderlisting of linkable objects in JSON""" utility = getUtility(ITinyMCE) linkable_portal_types = utility.linkable.split('\n') object = IJSONFolderListing(self.context, None) if object is None: return '' results = object.getListing(linkable_portal_types, rooted, document_base_url, 'File') return results
def test_json_listing_icon(self): self.portal.invokeFactory('File', id='somefile.bin') linkable_portal_types = self.utility.linkable.split('\n') linkable_portal_types.extend(self.utility.containsobjects.split('\n')) obj = IJSONFolderListing(self.portal) listing = obj.getListing( filter_portal_types=linkable_portal_types, rooted=False, document_base_url='http://nohost/plone', upload_type='File') self.assertRegexpMatches(listing, r'"icon": "<img width=\\"16\\" height=\\"16\\" src=\\"http://nohost/plone/application.png\\" alt=\\"File\\" />", "id": "somefile.bin"')
def jsonSCEmbedderFolderListing(self, rooted, document_base_url): """Returns the folderlisting of sc.embedder objects in JSON""" utility = getUtility(ITinyMCE) portal_types = ['sc.embedder'] portal_types.extend(utility.containsobjects.split('\n')) object = IJSONFolderListing(self.context, None) if object is None: return '' results = object.getListing(portal_types, rooted, document_base_url) return results
def jsonImageFolderListing(self, rooted, document_base_url): """Returns the folderlisting of image objects in JSON""" utility = getUtility(ITinyMCE) image_portal_types = utility.imageobjects.split('\n') image_portal_types.extend(utility.containsobjects.split('\n')) object = IJSONFolderListing(self.context, None) if object is None: return '' results = object.getListing(image_portal_types, rooted, document_base_url, 'Image') return results
def test_json_folder_listing_icon(self): self.portal.invokeFactory('File', id='somefile.bin') linkable_portal_types = self.utility.linkable.split('\n') linkable_portal_types.extend(self.utility.containsobjects.split('\n')) obj = IJSONFolderListing(self.portal) listing = obj.getListing( filter_portal_types=linkable_portal_types, rooted=False, document_base_url='http://nohost/plone', upload_type='File') self.assertRegexpMatches(listing, r'"icon": "<img width=\\"16\\" height=\\"16\\" src=\\"http://nohost/plone/application.png\\" alt=\\"File.*?\\" />", "id": "somefile.bin"')
def jsonLinkableFolderListing(self, rooted, document_base_url): """Returns the folderlisting of linkable objects in JSON""" utility = getToolByName(aq_inner(self.context), "portal_tinymce") linkable_portal_types = utility.linkable.split("\n") object = IJSONFolderListing(self.context, None) if object is None: return "" results = object.getListing( linkable_portal_types, rooted, document_base_url, "File", utility.imageobjects.split("\n") ) return results
def jsonImageFolderListing(self, rooted, document_base_url): """Returns the folderlisting of image objects in JSON""" utility = getToolByName(aq_inner(self.context), "portal_tinymce") image_portal_types = utility.imageobjects.split("\n") image_portal_types.extend(utility.containsobjects.split("\n")) object = IJSONFolderListing(self.context, None) if object is None: return "" results = object.getListing( image_portal_types, rooted, document_base_url, "Image", utility.imageobjects.split("\n") ) return results
def jsonLinkableFolderListing(self, rooted, document_base_url): """Returns the folderlisting of linkable objects in JSON""" utility = getToolByName(aq_inner(self.context), 'portal_tinymce') linkable_portal_types = utility.linkable.split('\n') object = IJSONFolderListing(self.context, None) if object is None: return '' results = object.getListing( linkable_portal_types, rooted, document_base_url, 'File', utility.imageobjects.split('\n'), ) return results
def test_json_folder_listing(self): # The folder listing is used in the link and image drawers to show the contents # of a folder. Let's see what items our current siteroot has. linkableportal_types = self.utility.linkable.split('\n') linkableportal_types.extend(self.utility.containsobjects.split('\n')) object = IJSONFolderListing(self.portal) self.assertRegexpMatches(object.getListing( filter_portal_types=linkableportal_types, rooted=False, document_base_url='http://nohost/plone', upload_type='File', ), '\{"parent_url": "", "path": \[.+],.+"items": \[.+]}') # Let's create some more content to get breadcrumbs. document = self.folder_object.invokeFactory('Document', id='document') # When we call the getListing method on the document we should get the listing of # its parent. obj = IJSONFolderListing(self.folder_object.get(document)) self.assertRegexpMatches(obj.getListing( filter_portal_types=[], rooted='False', document_base_url='http://nohost/plone/folder', ), '\{"parent_url": "http://nohost/plone".+}') # We can also select rooted so we don't get all the breadcrumbs. self.assertRegexpMatches(obj.getListing( filter_portal_types=[], rooted='True', document_base_url='http://nohost/plone/folder', ), '\{.*"path": \[{"url": "http://nohost/plone/folder".*}')
def test_json_folder_listing(self): # The folder listing is used in the link and image drawers to show the contents # of a folder. Let's see what items our current siteroot has. linkableportal_types = self.utility.linkable.split('\n') linkableportal_types.extend(self.utility.containsobjects.split('\n')) object = IJSONFolderListing(self.portal) listing = object.getListing( filter_portal_types=linkableportal_types, rooted=False, document_base_url='http://nohost/plone', upload_type='File') self.assertRegexpMatches(listing, '\{"parent_url": "", "path": \[.+],.+"items": \[.+]}') # no icon for regular contenttypes self.assertRegexpMatches(listing, '"icon": null') # This is easier to check more rigorously by turning the json # back to a Python dict. items = json.loads(listing)['items'] folder_item = [item for item in items if item[u'id'] == u'folder'][0] doc_item = [item for item in items if item[u'id'] == u'document'][0] self.assertEqual(folder_item[u'icon'], None) self.assertEqual(doc_item[u'icon'], None) # Let's create some more content to get breadcrumbs. document = self.folder_object.invokeFactory('Document', id='document') # When we call the getListing method on the document we should get the listing of # its parent. obj = IJSONFolderListing(self.folder_object.get(document)) listing = obj.getListing( filter_portal_types=[], rooted='False', document_base_url='http://nohost/plone/folder') self.assertRegexpMatches(listing, '\{"parent_url": "http://nohost/plone".+}') # We can also select rooted so we don't get all the breadcrumbs. listing = obj.getListing( filter_portal_types=[], rooted='True', document_base_url='http://nohost/plone/folder') self.assertRegexpMatches(listing, '\{.*"path": \[{"url": "http://nohost/plone/folder".*}')
def test_json_folder_listing_icon(self): self.portal.invokeFactory('File', id='somefile.bin') linkable_portal_types = self.utility.linkable.split('\n') linkable_portal_types.extend(self.utility.containsobjects.split('\n')) obj = IJSONFolderListing(self.portal) listing = obj.getListing( filter_portal_types=linkable_portal_types, rooted=False, document_base_url='http://nohost/plone', upload_type='File') self.assertRegexpMatches(listing, r'"icon": "<img width=\\"16\\" height=\\"16\\" src=\\"http://nohost/plone/application.png\\" alt=\\"File.*?\\" />"') # This is easier to check more rigorously by turning the json # back to a Python dict. items = json.loads(listing)['items'] file_item = [item for item in items if item[u'id'] == u'somefile.bin'][0] self.assertEqual(file_item[u'icon'], '<img width="16" height="16" src="http://nohost/plone/application.png" alt="File Octet Stream" />')
def test_json_folder_listing_icon(self): self.portal.invokeFactory('File', id='somefile.bin') linkable_portal_types = self.utility.linkable.split('\n') linkable_portal_types.extend(self.utility.containsobjects.split('\n')) obj = IJSONFolderListing(self.portal) listing = obj.getListing(filter_portal_types=linkable_portal_types, rooted=False, document_base_url='http://nohost/plone', upload_type='File') self.assertRegexpMatches( listing, r'"icon": "<img width=\\"16\\" height=\\"16\\" src=\\"http://nohost/plone/application.png\\" alt=\\"File.*?\\" />"' ) # This is easier to check more rigorously by turning the json # back to a Python dict. items = json.loads(listing)['items'] file_item = [item for item in items if item[u'id'] == u'somefile.bin'][0] self.assertEqual( file_item[u'icon'], '<img width="16" height="16" src="http://nohost/plone/application.png" alt="File Octet Stream" />' )
def test_json_folder_listing(self): # The folder listing is used in the link and image drawers to show the contents # of a folder. Let's see what items our current siteroot has. linkableportal_types = self.utility.linkable.split('\n') linkableportal_types.extend(self.utility.containsobjects.split('\n')) object = IJSONFolderListing(self.portal) listing = object.getListing(filter_portal_types=linkableportal_types, rooted=False, document_base_url='http://nohost/plone', upload_type='File') self.assertRegexpMatches( listing, '\{"parent_url": "", "path": \[.+],.+"items": \[.+]}') # no icon for regular contenttypes self.assertRegexpMatches(listing, '"icon": null') # This is easier to check more rigorously by turning the json # back to a Python dict. items = json.loads(listing)['items'] folder_item = [item for item in items if item[u'id'] == u'folder'][0] doc_item = [item for item in items if item[u'id'] == u'document'][0] self.assertEqual(folder_item[u'icon'], None) self.assertEqual(doc_item[u'icon'], None) # Let's create some more content to get breadcrumbs. document = self.folder_object.invokeFactory('Document', id='document') # When we call the getListing method on the document we should get the listing of # its parent. obj = IJSONFolderListing(self.folder_object.get(document)) listing = obj.getListing( filter_portal_types=[], rooted='False', document_base_url='http://nohost/plone/folder') self.assertRegexpMatches(listing, '\{"parent_url": "http://nohost/plone".+}') # We can also select rooted so we don't get all the breadcrumbs. listing = obj.getListing( filter_portal_types=[], rooted='True', document_base_url='http://nohost/plone/folder') self.assertRegexpMatches( listing, '\{.*"path": \[{"url": "http://nohost/plone/folder".*}')