From f066230157c74e3e6399298ad1abe054ef08a494 Mon Sep 17 00:00:00 2001 From: "Jens W. Klein" Date: Thu, 20 Oct 2016 23:22:25 -0400 Subject: [PATCH 1/2] get rid of completly (in whole core) unused plone_scripts --- CHANGES.rst | 12 ++++ .../skins/plone_scripts/add_ext_editor.py | 27 --------- .../plone_scripts/author_find_content.py | 48 ---------------- .../plone_scripts/create_query_string.py | 36 ------------ .../plone_scripts/getGlobalPortalRoles.py | 10 ---- .../skins/plone_scripts/getPopupScript.py | 16 ------ .../skins/plone_scripts/getPortalTypeList.py | 57 ------------------- .../skins/plone_scripts/getPortalTypes.py | 15 ----- .../CMFPlone/skins/plone_scripts/plone_log.py | 13 ----- .../plone_scripts/sort_modified_ascending.py | 12 ---- 10 files changed, 12 insertions(+), 234 deletions(-) delete mode 100644 Products/CMFPlone/skins/plone_scripts/add_ext_editor.py delete mode 100644 Products/CMFPlone/skins/plone_scripts/author_find_content.py delete mode 100644 Products/CMFPlone/skins/plone_scripts/create_query_string.py delete mode 100644 Products/CMFPlone/skins/plone_scripts/getGlobalPortalRoles.py delete mode 100644 Products/CMFPlone/skins/plone_scripts/getPopupScript.py delete mode 100644 Products/CMFPlone/skins/plone_scripts/getPortalTypeList.py delete mode 100644 Products/CMFPlone/skins/plone_scripts/getPortalTypes.py delete mode 100644 Products/CMFPlone/skins/plone_scripts/plone_log.py delete mode 100644 Products/CMFPlone/skins/plone_scripts/sort_modified_ascending.py diff --git a/CHANGES.rst b/CHANGES.rst index 38516125f4..ce5a65dc38 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -21,6 +21,18 @@ Breaking changes: - MimetypesRegistry icons are now a browser resource directory instead of skins folder. [jensens] +- Remove unused ``plone_scripts`` (not used nor tested anywhere in coredev) [jensens] + + - ``add_ext_editor.py`` + - ``author_find_content.py`` + - ``create_query_string.py`` + - ``getGlobalPortalRoles.py`` + - ``getPopupScript.py`` + - ``getPortalTypeList.py`` + - ``getPortalTypes.py`` + - ``plone_log.py`` + - ``sort_modified_ascending.py`` + New features: - Add sort_on field to search controlpanel. diff --git a/Products/CMFPlone/skins/plone_scripts/add_ext_editor.py b/Products/CMFPlone/skins/plone_scripts/add_ext_editor.py deleted file mode 100644 index 565abbcd74..0000000000 --- a/Products/CMFPlone/skins/plone_scripts/add_ext_editor.py +++ /dev/null @@ -1,27 +0,0 @@ -## Script (Python) "add_ext_editor" -##bind container=container -##bind context=context -##bind namespace= -##bind script=script -##bind subpath=traverse_subpath -##parameters= -##title=adds ext_edit actions to types - -types = context.portal_types -omit_types = ('Folder', 'Discussion Item', 'Event', 'Topic', 'Collector', - 'Collector Issue', 'Collector Issue Transcript', - 'Collector Subset') -for ctype in [ctype for ctype in types.objectValues() - if ctype.Title() not in omit_types]: - try: - ctype.getActionById('external_edit') - except (TypeError, KeyError, ValueError): - ctype.addAction('external_edit', - 'External Editor', - 'external_edit', - 'Modify portal content', - 'object', - visible=0) -context.portal_properties.site_properties \ - .manage_changeProperties({'ext_editor': 1}) -return 'Successfully configured system to use External Editor.' diff --git a/Products/CMFPlone/skins/plone_scripts/author_find_content.py b/Products/CMFPlone/skins/plone_scripts/author_find_content.py deleted file mode 100644 index df3316d09f..0000000000 --- a/Products/CMFPlone/skins/plone_scripts/author_find_content.py +++ /dev/null @@ -1,48 +0,0 @@ -## Script (Python) "author_find_content" -##bind container=container -##bind context=context -##bind namespace= -##bind script=script -##bind subpath=traverse_subpath -##parameters=author,limit_per_type=5,path=None -##title=Find content created by a specific author - -from Products.CMFCore.utils import getToolByName -from Products.CMFPlone.browser.navtree import getNavigationRoot - -catalog = getToolByName(context, 'portal_catalog') -utils = getToolByName(context, 'plone_utils') - -friendly_types = utils.getUserFriendlyTypes() - -found = {} -if path is None: - path = getNavigationRoot(context) - -content = catalog.searchResults(dict( - Creator=author, - portal_type=friendly_types, - sort_on='modified', - sort_order='reverse', - path=path)) - -for item in content: - itemType = item.portal_type - - if not itemType in found: - found[itemType] = [] - if len(found[itemType]) < limit_per_type: - found[itemType].append(item) - -## The end result is a dictionary of lists, where the keys are the actual -## portal types. This means they are in rather random order.. - -types = found.keys() -types.sort() - -results = [] - -for t in types: - results.append({'portal_type': t, 'content_items': found[t]}) - -return results diff --git a/Products/CMFPlone/skins/plone_scripts/create_query_string.py b/Products/CMFPlone/skins/plone_scripts/create_query_string.py deleted file mode 100644 index 039fd7b241..0000000000 --- a/Products/CMFPlone/skins/plone_scripts/create_query_string.py +++ /dev/null @@ -1,36 +0,0 @@ -## Script (Python) "create_query_string" -##bind container=container -##bind context=context -##bind namespace= -##bind script=script -##bind subpath=traverse_subpath -##parameters=qs=None, **kw -##title=Creates a query string based on existing string plus keyword arguments - -from zExceptions import Forbidden -if container.REQUEST.get('PUBLISHED') is script: - raise Forbidden('Script may not be published.') - -from Products.PythonScripts.standard import url_quote_plus - -L = [] - -if qs: - # break an existing query string into key value pairs - entityparts = qs.split('&') - for entitypart in entityparts: - ampparts = entitypart.split('&') - for amppart in ampparts: - tmp = amppart.split('=', 1) - if len(tmp) > 1: - k, v = tmp - else: - k, v = tmp[0], '' - L.append((k, v)) -else: - for k, v in kw.items(): - L.append((k, url_quote_plus(v))) - -# separate k/v pairs with & (dont blame me, see the RFC) -new = '&'.join(['%s=%s' % (k, v) for k, v in L]) -return new diff --git a/Products/CMFPlone/skins/plone_scripts/getGlobalPortalRoles.py b/Products/CMFPlone/skins/plone_scripts/getGlobalPortalRoles.py deleted file mode 100644 index 27b6863687..0000000000 --- a/Products/CMFPlone/skins/plone_scripts/getGlobalPortalRoles.py +++ /dev/null @@ -1,10 +0,0 @@ -## Script (Python) "getGlobalPortalRoles" -##bind container=container -##bind context=context -##bind namespace= -##bind script=script -##bind subpath=traverse_subpath -##parameters= -##title= - -return [r for r in context.portal_membership.getPortalRoles() if r != 'Owner'] diff --git a/Products/CMFPlone/skins/plone_scripts/getPopupScript.py b/Products/CMFPlone/skins/plone_scripts/getPopupScript.py deleted file mode 100644 index d4e2cb2825..0000000000 --- a/Products/CMFPlone/skins/plone_scripts/getPopupScript.py +++ /dev/null @@ -1,16 +0,0 @@ -##parameters=input_id - -from zExceptions import Forbidden - -if container.REQUEST.get('PUBLISHED') is script: - raise Forbidden('Script may not be published.') - - -return r""" - -function returndate(day) -{ - opener.document.getElementById('%s').value = day; - window.close(); -} -""" % input_id diff --git a/Products/CMFPlone/skins/plone_scripts/getPortalTypeList.py b/Products/CMFPlone/skins/plone_scripts/getPortalTypeList.py deleted file mode 100644 index 6abf6db24e..0000000000 --- a/Products/CMFPlone/skins/plone_scripts/getPortalTypeList.py +++ /dev/null @@ -1,57 +0,0 @@ -## Script (Python) "getPortalTypeList" -##bind container=container -##bind context=context -##bind namespace= -##bind script=script -##bind subpath=traverse_subpath -##parameters= -##title= - -from Products.CMFCore.utils import getToolByName - -pt_tool = getToolByName(context, 'portal_types') -plone_utils = getToolByName(context, 'plone_utils') -normalizeString = plone_utils.normalizeString - -type_info = pt_tool.listTypeInfo() - -excluded_ids = { - 'TempFolder': None, - 'CMF Document': None, - 'CMF Event': None, - 'CMF File': None, - 'CMF Folder': None, - 'CMF Image': None, - 'CMF Large Plone Folder': None, - 'CMF Link': None, - 'CMF News Item': None, - 'CMF Topic': None, - 'ATCurrentAuthorCriterion': None, - 'ATDateRangeCriterion': None, - 'ATDateCriteria': None, - 'ATListCriterion': None, - 'ATPathCriterion': None, - 'ATRelativePathCriterion': None, - 'ATPortalTypeCriterion': None, - 'ATReferenceCriterion': None, - 'ATBooleanCriterion': None, - 'ATSelectionCriterion': None, - 'ATSimpleIntCriterion': None, - 'ATSimpleStringCriterion': None, - 'ATSortCriterion': None, -} - -result = [] -for item in type_info: - item_id = item.getId() - if item_id not in excluded_ids: - result.append({ - 'id': normalizeString(item_id), - 'icon': item.getIcon(), - }) - -result = [(x['id'], x) for x in result] -result.sort() -result = [x[-1] for x in result] - -return result diff --git a/Products/CMFPlone/skins/plone_scripts/getPortalTypes.py b/Products/CMFPlone/skins/plone_scripts/getPortalTypes.py deleted file mode 100644 index 7f8429eede..0000000000 --- a/Products/CMFPlone/skins/plone_scripts/getPortalTypes.py +++ /dev/null @@ -1,15 +0,0 @@ -## Script (Python) "getPortalTypes" -##bind container=container -##bind context=context -##bind namespace= -##bind script=script -##bind subpath=traverse_subpath -##parameters= -##title=Return a list of the content types installed in the portal - -from Products.CMFCore.utils import getToolByName - -portal_types_tool = getToolByName(context, 'portal_types') -installed_types = portal_types_tool.listContentTypes() - -return installed_types diff --git a/Products/CMFPlone/skins/plone_scripts/plone_log.py b/Products/CMFPlone/skins/plone_scripts/plone_log.py deleted file mode 100644 index 116d35484f..0000000000 --- a/Products/CMFPlone/skins/plone_scripts/plone_log.py +++ /dev/null @@ -1,13 +0,0 @@ -## Script (Python) "plone_log" -##bind container=container -##bind context=context -##bind namespace= -##bind script=script -##bind subpath=traverse_subpath -##parameters=summary='',text='' -##title= - -from logging import getLogger - -log = getLogger('Plone') -log.info('Debug: %s \n%s', summary, text) diff --git a/Products/CMFPlone/skins/plone_scripts/sort_modified_ascending.py b/Products/CMFPlone/skins/plone_scripts/sort_modified_ascending.py deleted file mode 100644 index 93ba68a60f..0000000000 --- a/Products/CMFPlone/skins/plone_scripts/sort_modified_ascending.py +++ /dev/null @@ -1,12 +0,0 @@ -## Script (Python) "sort_modified_ascending" -##bind container=container -##bind context=context -##bind namespace= -##bind script=script -##bind subpath=traverse_subpath -##parameters=catalog_sequence -##title= - -sorted = catalog_sequence[:] -sorted.sort(lambda x, y: cmp(x.modified(), y.modified())) -return sorted From dfa3616f931e7c4bacb46d169b144705027f63a9 Mon Sep 17 00:00:00 2001 From: "Jens W. Klein" Date: Fri, 21 Oct 2016 14:04:58 -0400 Subject: [PATCH 2/2] remove unused assignment in content_status_modify.cpy --- .../CMFPlone/skins/plone_form_scripts/content_status_modify.cpy | 1 - 1 file changed, 1 deletion(-) diff --git a/Products/CMFPlone/skins/plone_form_scripts/content_status_modify.cpy b/Products/CMFPlone/skins/plone_form_scripts/content_status_modify.cpy index 902128abd2..6aaa1ba683 100644 --- a/Products/CMFPlone/skins/plone_form_scripts/content_status_modify.cpy +++ b/Products/CMFPlone/skins/plone_form_scripts/content_status_modify.cpy @@ -17,7 +17,6 @@ from Products.CMFCore.utils import getToolByName plone_utils = getToolByName(context, 'plone_utils') contentEditSuccess = 0 -plone_log = context.plone_log portal_factory = getattr(context, 'portal_factory', None) if portal_factory is not None: new_context = context.portal_factory.doCreate(context)