Skip to content

Commit

Permalink
Merge pull request #192 from plone/zope5
Browse files Browse the repository at this point in the history
Fixed WrongContainedType for hostnameBlackList on Zope 5.
  • Loading branch information
jensens authored Sep 24, 2020
2 parents 9656803 + 8a67c21 commit a784c2f
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
3 changes: 3 additions & 0 deletions news/183.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Fixed WrongContainedType for hostnameBlackList on Zope 5.
See also `issue 183 <https://github.com/plone/plone.app.theming/issues/183>`_.
[maurits]
4 changes: 2 additions & 2 deletions src/plone/app/theming/browser/controlpanel.pt
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,7 @@
<div
tal:define="error errors/hostnameBlacklist | nothing;
hostnameBlacklist view/theme_settings/hostnameBlacklist | python:[];
hostnameBlacklist python:request.get('hostnameBlacklist', hostnameBlacklist)"
hostnameBlacklist python: view.hostname_blacklist or hostnameBlacklist"
tal:attributes="class python:'field error' if error else 'field'">

<label for="hostnameBlacklist" i18n:translate="label_hostname_blacklist">Unthemed host names</label>
Expand All @@ -481,7 +481,7 @@
id="hostnameBlacklist"
rows="5"
cols="50"
tal:content="python:'\n'.join(hostnameBlacklist)"
tal:content="python: '\n'.join(hostnameBlacklist)"
></textarea>

</div>
Expand Down
12 changes: 9 additions & 3 deletions src/plone/app/theming/browser/controlpanel.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
from plone.resource.utils import queryResourceDirectory
from Products.CMFCore.utils import getToolByName
from Products.CMFPlone.utils import safe_unicode
from Products.CMFPlone.utils import safe_nativestring
from Products.CMFPlone.interfaces import ILinkSchema
from Products.statusmessages.interfaces import IStatusMessage
from zope.component import getMultiAdapter
Expand Down Expand Up @@ -60,6 +61,13 @@ def site_url(self):
"""
return getSite().absolute_url()

@property
def hostname_blacklist(self):
hostname_blacklist = self.request.get('hostnameBlacklist', [])
if six.PY2:
return hostname_blacklist
return [safe_nativestring(host) for host in hostname_blacklist]

def __call__(self):
self.pskin = getToolByName(self.context, 'portal_skins')
if self.update():
Expand Down Expand Up @@ -175,8 +183,6 @@ def update(self):
prefix = form.get('absolutePrefix', None)
doctype = str(form.get('doctype', ""))

hostnameBlacklist = form.get('hostnameBlacklist', [])

parameterExpressions = {}
parameterExpressionsList = form.get('parameterExpressions', [])

Expand Down Expand Up @@ -210,7 +216,7 @@ def update(self):
self.theme_settings.rules = rules
self.theme_settings.absolutePrefix = prefix
self.theme_settings.parameterExpressions = parameterExpressions
self.theme_settings.hostnameBlacklist = hostnameBlacklist
self.theme_settings.hostnameBlacklist = self.hostname_blacklist
if custom_css != self.theme_settings.custom_css:
self.theme_settings.custom_css_timestamp = datetime.now()
self.theme_settings.custom_css = custom_css
Expand Down

0 comments on commit a784c2f

Please sign in to comment.