From 09d2989392b9e5dcd2757f90c587290681d9744d Mon Sep 17 00:00:00 2001 From: Philip Bauer Date: Sun, 11 Nov 2018 07:41:58 +0900 Subject: [PATCH 1/4] add support for python3 --- collective/js/jqueryui/controlpanel.py | 2 +- collective/js/jqueryui/resources.py | 24 +++++++----------------- 2 files changed, 8 insertions(+), 18 deletions(-) diff --git a/collective/js/jqueryui/controlpanel.py b/collective/js/jqueryui/controlpanel.py index c813fa1..f41b622 100644 --- a/collective/js/jqueryui/controlpanel.py +++ b/collective/js/jqueryui/controlpanel.py @@ -198,7 +198,7 @@ def verify_jsregistry(record): site = getSite() jsregistry = site.portal_javascripts - keys = JQUERYUI_DEPENDENCIES.keys() + keys = list(JQUERYUI_DEPENDENCIES.keys()) for key in keys: rkey = key.replace('.', '_') resource_id = RESOURCE_ID % key diff --git a/collective/js/jqueryui/resources.py b/collective/js/jqueryui/resources.py index 632dd0c..340daa1 100644 --- a/collective/js/jqueryui/resources.py +++ b/collective/js/jqueryui/resources.py @@ -1,22 +1,16 @@ import logging from copy import copy from zope import component -from StringIO import StringIO -try: - from zope.component.hooks import getSite -except ImportError: - #BBB - from zope.site.hooks import getSite +from six import StringIO from plone.registry.interfaces import IRegistry from Products.CMFCore.utils import getToolByName +from Products.CMFPlone.utils import safe_unicode from Products.Five import BrowserView from Products.ResourceRegistries.tools.packer import CSSPacker from Products.ResourceRegistries.tools.packer import JavascriptPacker from Products.ResourceRegistries.utils import applyPrefix - from collective.js.jqueryui import interfaces, config -from Acquisition import aq_parent logger = logging.getLogger('collective.js.jqueryui') @@ -85,7 +79,7 @@ def get_resources_content(self, resources): try: resource = self.context.restrictedTraverse( resourceid) - except KeyError, e: + except KeyError as e: logger.error(e) continue if not resource: @@ -102,13 +96,9 @@ def get_resources_content(self, resources): fic = open(resource.context.path, 'r') content = fic.read() fic.close() - try: - content = unicode(content) - - except Exception, e: - content = unicode(content.decode('utf-8')) + content = safe_unicode(content) - #css applyPrefix + # css applyPrefix if self._css: upath = upath.rstrip('/') prefix = '/'.join([upath, resourceid]) @@ -118,7 +108,7 @@ def get_resources_content(self, resources): prefix.split('/')[:-1]) content = applyPrefix(content, prefix) - #content is already minified + # content is already minified data.write(content) data.write(u"\n") @@ -141,7 +131,7 @@ def get_resources(self): portal_registry""" settings = self.settings() deps = config.JQUERYUI_DEPENDENCIES - alljs = deps.keys() + alljs = list(deps.keys()) resources = [] wanted = [] # not ordered list of wanted plugins tpl = "++resource++jquery-ui/jquery.%s.min.js" From 49eea09e55ce87131bd9fb686fe9a923cf9b9b0c Mon Sep 17 00:00:00 2001 From: Peter Holzer Date: Fri, 8 Feb 2019 12:32:45 +0100 Subject: [PATCH 2/4] Added uninstall profile --- .gitignore | 1 + CHANGES.rst | 3 +++ collective/js/jqueryui/profiles.zcml | 9 +++++++++ .../jqueryui/profiles/uninstall/actions.xml | 6 ++++++ .../profiles/uninstall/browserlayer.xml | 7 +++++++ .../profiles/uninstall/controlpanel.xml | 20 +++++++++++++++++++ .../jqueryui/profiles/uninstall/registry.xml | 4 ++++ 7 files changed, 50 insertions(+) create mode 100644 collective/js/jqueryui/profiles/uninstall/actions.xml create mode 100644 collective/js/jqueryui/profiles/uninstall/browserlayer.xml create mode 100644 collective/js/jqueryui/profiles/uninstall/controlpanel.xml create mode 100644 collective/js/jqueryui/profiles/uninstall/registry.xml diff --git a/.gitignore b/.gitignore index 3e3f6ae..50b1c19 100644 --- a/.gitignore +++ b/.gitignore @@ -28,3 +28,4 @@ testrelease include/ lib/ +.DS_Store diff --git a/CHANGES.rst b/CHANGES.rst index a55d28f..a0e4707 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -8,6 +8,9 @@ JQueryUI Changelog: http://jqueryui.com/changelog/ Bug fixes: +- Added uninstall profile + [agitator] + - Simplify resource registration for Plone 5 the way done in https://github.com/collective/example.p4p5#cssjs-declaration-in-plone-5 [rnix] diff --git a/collective/js/jqueryui/profiles.zcml b/collective/js/jqueryui/profiles.zcml index f213d8e..e33ba4f 100644 --- a/collective/js/jqueryui/profiles.zcml +++ b/collective/js/jqueryui/profiles.zcml @@ -30,6 +30,15 @@ description="Install jQuery UI." provides="Products.GenericSetup.interfaces.EXTENSION" /> + + + diff --git a/collective/js/jqueryui/profiles/uninstall/actions.xml b/collective/js/jqueryui/profiles/uninstall/actions.xml new file mode 100644 index 0000000..f0b26a6 --- /dev/null +++ b/collective/js/jqueryui/profiles/uninstall/actions.xml @@ -0,0 +1,6 @@ + + + + + diff --git a/collective/js/jqueryui/profiles/uninstall/browserlayer.xml b/collective/js/jqueryui/profiles/uninstall/browserlayer.xml new file mode 100644 index 0000000..9697923 --- /dev/null +++ b/collective/js/jqueryui/profiles/uninstall/browserlayer.xml @@ -0,0 +1,7 @@ + + + + diff --git a/collective/js/jqueryui/profiles/uninstall/controlpanel.xml b/collective/js/jqueryui/profiles/uninstall/controlpanel.xml new file mode 100644 index 0000000..dcedde7 --- /dev/null +++ b/collective/js/jqueryui/profiles/uninstall/controlpanel.xml @@ -0,0 +1,20 @@ + + + + + + + diff --git a/collective/js/jqueryui/profiles/uninstall/registry.xml b/collective/js/jqueryui/profiles/uninstall/registry.xml new file mode 100644 index 0000000..60bff4b --- /dev/null +++ b/collective/js/jqueryui/profiles/uninstall/registry.xml @@ -0,0 +1,4 @@ + + + + From 51463163db63057041a71264c1064fdf5f9e806b Mon Sep 17 00:00:00 2001 From: Peter Holzer Date: Fri, 8 Feb 2019 12:58:57 +0100 Subject: [PATCH 3/4] update changelog & classifiers --- CHANGES.rst | 3 +++ setup.py | 2 ++ 2 files changed, 5 insertions(+) diff --git a/CHANGES.rst b/CHANGES.rst index a0e4707..3498fda 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -11,6 +11,9 @@ Bug fixes: - Added uninstall profile [agitator] +- Python 2/3 compatibility + [pbauer] + - Simplify resource registration for Plone 5 the way done in https://github.com/collective/example.p4p5#cssjs-declaration-in-plone-5 [rnix] diff --git a/setup.py b/setup.py index 93b5438..507e36d 100644 --- a/setup.py +++ b/setup.py @@ -22,6 +22,8 @@ "Programming Language :: Python", "Programming Language :: Python :: 2.6", "Programming Language :: Python :: 2.7", + "Programming Language :: Python :: 3.6", + "Programming Language :: Python :: 3.7", ], keywords='plone jqueryui', author='JeanMichel FRANCOIS aka toutpt', From b47b20c71521a088e4413119e6bae57b9966926a Mon Sep 17 00:00:00 2001 From: Peter Holzer Date: Fri, 8 Feb 2019 13:30:54 +0100 Subject: [PATCH 4/4] update metadata.xml and uninstall profile --- collective/js/jqueryui/profiles/default/metadata.xml | 2 +- collective/js/jqueryui/profiles/uninstall/registry.xml | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/collective/js/jqueryui/profiles/default/metadata.xml b/collective/js/jqueryui/profiles/default/metadata.xml index 24b1137..58b9ffd 100644 --- a/collective/js/jqueryui/profiles/default/metadata.xml +++ b/collective/js/jqueryui/profiles/default/metadata.xml @@ -1,6 +1,6 @@ - 3203 + 3204 profile-collective.js.jqueryui:install-base diff --git a/collective/js/jqueryui/profiles/uninstall/registry.xml b/collective/js/jqueryui/profiles/uninstall/registry.xml index 60bff4b..002aa7a 100644 --- a/collective/js/jqueryui/profiles/uninstall/registry.xml +++ b/collective/js/jqueryui/profiles/uninstall/registry.xml @@ -1,4 +1,7 @@ + +