Closed agitator closed 1 year ago
@gforcada @loechel the change in https://github.com/plone/Products.CMFPlone/pull/2107 is giving us headaches. compiling legacy scripts/css fails for us with:
2017-11-17 14:50:26 INFO Products.CMFPlone Cooking css ++resource++plone.app.event/event.css
2017-11-17 14:50:26 INFO Products.CMFPlone Cooking js ++resource++plone.app.event/event.js
2017-11-17 14:50:26 INFO Products.CMFPlone Cooking js ++resource++plone.app.discussion.javascripts/comments.js
2017-11-17 14:50:26 INFO Products.CMFPlone Cooking css ++resource++collective.z3cform.datagridfield/datagridfield.css
2017-11-17 14:50:26 INFO Products.CMFPlone Cooking js ++resource++collective.z3cform.datagridfield/datagridfield.js
2017-11-17 14:50:26 INFO Products.CMFPlone Cooking css ++resource++sfama_event_reg/eventregistration.css
2017-11-17 14:50:26 INFO Products.CMFPlone Cooking js ++resource++sfama_event_reg/eventregistration-disable-validation.js
2017-11-17 14:50:26 INFO Products.CMFPlone Cooking css ++resource++plone.formwidget.autocomplete/jquery.autocomplete.css
2017-11-17 14:50:26 INFO Products.CMFPlone Cooking js ++resource++plone.formwidget.autocomplete/jquery.autocomplete.min.js
2017-11-17 14:50:26 INFO Products.CMFPlone Cooking js ++resource++plone.formwidget.autocomplete/formwidget-autocomplete.js
2017-11-17 14:50:26 INFO Products.CMFPlone Cooking css ++plone++easynewsletter/easynewsletter.less
2017-11-17 14:50:26 ERROR plone.app.viewletmanager Error while rendering viewlet-manager=plone.htmlhead.links, viewlet=plone.resourceregistries.styles
Traceback (most recent call last):
File "/home/_thet/repos-config/dotfiles-thet/dot.buildout/eggs/plone.app.viewletmanager-2.0.10-py2.7.egg/plone/app/viewletmanager/manager.py", line 112, in render
html.append(viewlet.render())
File "/home/_thet/repos-config/dotfiles-thet/dot.buildout/eggs/plone.app.layout-2.7.4-py2.7.egg/plone/app/layout/viewlets/common.py", line 59, in render
return self.index()
File "/home/_thet/repos-config/dotfiles-thet/dot.buildout/eggs/Zope2-2.13.26-py2.7.egg/Products/Five/browser/pagetemplatefile.py", line 125, in __call__
return self.im_func(im_self, *args, **kw)
File "/home/_thet/repos-config/dotfiles-thet/dot.buildout/eggs/Zope2-2.13.26-py2.7.egg/Products/Five/browser/pagetemplatefile.py", line 59, in __call__
sourceAnnotations=getattr(debug_flags, 'sourceAnnotations', 0),
File "/home/_thet/repos-config/dotfiles-thet/dot.buildout/eggs/zope.pagetemplate-4.2.1-py2.7.egg/zope/pagetemplate/pagetemplate.py", line 137, in pt_render
strictinsert=0, sourceAnnotations=sourceAnnotations
File "/home/_thet/repos-config/dotfiles-thet/dot.buildout/eggs/five.pt-2.2.4-py2.7.egg/five/pt/engine.py", line 98, in __call__
return self.template.render(**kwargs)
File "/home/_thet/repos-config/dotfiles-thet/dot.buildout/eggs/z3c.pt-3.0.0a1-py2.7.egg/z3c/pt/pagetemplate.py", line 163, in render
return base_renderer(**context)
File "/home/_thet/repos-config/dotfiles-thet/dot.buildout/eggs/Chameleon-2.25-py2.7.egg/chameleon/zpt/template.py", line 261, in render
return super(PageTemplate, self).render(**vars)
File "/home/_thet/repos-config/dotfiles-thet/dot.buildout/eggs/Chameleon-2.25-py2.7.egg/chameleon/template.py", line 191, in render
raise_with_traceback(exc, tb)
File "/home/_thet/repos-config/dotfiles-thet/dot.buildout/eggs/Chameleon-2.25-py2.7.egg/chameleon/template.py", line 171, in render
self._render(stream, econtext, rcontext)
File "1743e5a7e7d68cbcf7c65d874f94307a.py", line 88, in render
File "/home/_thet/repos-config/dotfiles-thet/dot.buildout/eggs/five.pt-2.2.4-py2.7.egg/five/pt/expressions.py", line 161, in __call__
return base()
File "/home/_thet/data/dev/agitator/sfama.buildout/srccore/Products.CMFPlone/Products/CMFPlone/resources/browser/styles.py", line 90, in styles
result = self.ordered_bundles_result()
File "/home/_thet/data/dev/agitator/sfama.buildout/srccore/Products.CMFPlone/Products/CMFPlone/resources/browser/resource.py", line 222, in ordered_bundles_result
self.get_data(bundle, result)
File "/home/_thet/data/dev/agitator/sfama.buildout/srccore/Products.CMFPlone/Products/CMFPlone/resources/browser/styles.py", line 58, in get_data
cookWhenChangingSettings(self.context, bundle)
File "/home/_thet/data/dev/agitator/sfama.buildout/srccore/Products.CMFPlone/Products/CMFPlone/resources/browser/cook.py", line 97, in cookWhenChangingSettings
css = css_compiler.compile_string(css)
File "/home/_thet/repos-config/dotfiles-thet/dot.buildout/eggs/pyScss-1.3.5-py2.7-linux-x86_64.egg/scss/compiler.py", line 217, in compile_string
return self.call_and_catch_errors(compilation.run)
File "/home/_thet/repos-config/dotfiles-thet/dot.buildout/eggs/pyScss-1.3.5-py2.7-linux-x86_64.egg/scss/compiler.py", line 176, in call_and_catch_errors
return f(*args, **kwargs)
File "/home/_thet/repos-config/dotfiles-thet/dot.buildout/eggs/pyScss-1.3.5-py2.7-linux-x86_64.egg/scss/compiler.py", line 296, in run
self.manage_children(rule, scope=None)
File "/home/_thet/repos-config/dotfiles-thet/dot.buildout/eggs/pyScss-1.3.5-py2.7-linux-x86_64.egg/scss/compiler.py", line 349, in manage_children
self._manage_children_impl(rule, scope)
File "/home/_thet/repos-config/dotfiles-thet/dot.buildout/eggs/pyScss-1.3.5-py2.7-linux-x86_64.egg/scss/compiler.py", line 398, in _manage_children_impl
self._nest_rules(rule, scope, block)
File "/home/_thet/repos-config/dotfiles-thet/dot.buildout/eggs/pyScss-1.3.5-py2.7-linux-x86_64.egg/scss/compiler.py", line 1203, in _nest_rules
self.manage_children(new_rule, scope)
File "/home/_thet/repos-config/dotfiles-thet/dot.buildout/eggs/pyScss-1.3.5-py2.7-linux-x86_64.egg/scss/compiler.py", line 349, in manage_children
self._manage_children_impl(rule, scope)
File "/home/_thet/repos-config/dotfiles-thet/dot.buildout/eggs/pyScss-1.3.5-py2.7-linux-x86_64.egg/scss/compiler.py", line 383, in _manage_children_impl
self._get_properties(rule, scope, block)
File "/home/_thet/repos-config/dotfiles-thet/dot.buildout/eggs/pyScss-1.3.5-py2.7-linux-x86_64.egg/scss/compiler.py", line 1090, in _get_properties
value = calculator.calculate(raw_value)
File "/home/_thet/repos-config/dotfiles-thet/dot.buildout/eggs/pyScss-1.3.5-py2.7-linux-x86_64.egg/scss/calculator.py", line 116, in calculate
result = self.evaluate_expression(expression, divide=divide)
File "/home/_thet/repos-config/dotfiles-thet/dot.buildout/eggs/pyScss-1.3.5-py2.7-linux-x86_64.egg/scss/calculator.py", line 134, in evaluate_expression
ast = self.parse_expression(expr)
File "/home/_thet/repos-config/dotfiles-thet/dot.buildout/eggs/pyScss-1.3.5-py2.7-linux-x86_64.egg/scss/calculator.py", line 167, in parse_expression
ast = getattr(parser, target)()
File "/home/_thet/repos-config/dotfiles-thet/dot.buildout/eggs/pyScss-1.3.5-py2.7-linux-x86_64.egg/scss/grammar/expression.py", line 110, in goal
expr_lst = self.expr_lst()
File "/home/_thet/repos-config/dotfiles-thet/dot.buildout/eggs/pyScss-1.3.5-py2.7-linux-x86_64.egg/scss/grammar/expression.py", line 199, in expr_lst
expr_slst = self.expr_slst()
File "/home/_thet/repos-config/dotfiles-thet/dot.buildout/eggs/pyScss-1.3.5-py2.7-linux-x86_64.egg/scss/grammar/expression.py", line 208, in expr_slst
or_expr = self.or_expr()
File "/home/_thet/repos-config/dotfiles-thet/dot.buildout/eggs/pyScss-1.3.5-py2.7-linux-x86_64.egg/scss/grammar/expression.py", line 216, in or_expr
and_expr = self.and_expr()
File "/home/_thet/repos-config/dotfiles-thet/dot.buildout/eggs/pyScss-1.3.5-py2.7-linux-x86_64.egg/scss/grammar/expression.py", line 225, in and_expr
not_expr = self.not_expr()
File "/home/_thet/repos-config/dotfiles-thet/dot.buildout/eggs/pyScss-1.3.5-py2.7-linux-x86_64.egg/scss/grammar/expression.py", line 234, in not_expr
_token_ = self._peek(self.argspec_item_chks)
File "/home/_thet/repos-config/dotfiles-thet/dot.buildout/eggs/pyScss-1.3.5-py2.7-linux-x86_64.egg/scss/grammar/scanner.py", line 141, in _peek
tok = self._scanner.token(self._pos, types)
File "/home/_thet/repos-config/dotfiles-thet/dot.buildout/eggs/pyScss-1.3.5-py2.7-linux-x86_64.egg/scss/grammar/scanner.py", line 270, in token
tokens_len += self._scan(restrict)
File "/home/_thet/data/dev/agitator/sfama.buildout/srcsfama/sfama.site/src/sfama/site/patches.py", line 49, in patchedScan
raise SassSyntaxError(self.input, self.pos, restrict)
SassSyntaxError: Syntax error: Found u'@plone-def' but expected one of ADD, ALPHA_FUNCTION, BANG_IMPORTANT, BAREWORD, COLOR, DOUBLE_QUOTE, FNCT, IF_FUNCTION, INTERP_START, LITERAL_FUNCTION, LPAR, NOT, NUM, SIGN, SINGLE_QUOTE, URL_FUNCTION, VAR
- Expression: "view/styles"
- Filename: ... s.CMFPlone/Products/CMFPlone/resources/browser/styles.pt
- Location: (line 1: col 26)
- Source: <tal:styles repeat="style view/styles"
^^^^^^^^^^^
- Arguments: repeat: {...} (0)
template: <ViewPageTemplateFile - at 0x7f2d142cc6d0>
views: <ViewMapper - at 0x7f2d142cc3d0>
modules: <instance - at 0x7f2d226ae440>
args: <tuple - at 0x7f2d2b24a050>
here: <ImplicitAcquisitionWrapper Plone at 0x7f2d18836fa0>
user: <ImplicitAcquisitionWrapper - at 0x7f2d1885f730>
nothing: <NoneType - at 0x5586dfe28560>
container: <ImplicitAcquisitionWrapper Plone at 0x7f2d18836fa0>
request: <instance - at 0x7f2d16285b90>
wrapped_repeat: <SafeMapping - at 0x7f2d15a65680>
traverse_subpath: <list - at 0x7f2d17f8fb90>
default: <object - at 0x7f2d2b19d540>
loop: {...} (0)
context: <ImplicitAcquisitionWrapper Plone at 0x7f2d18836fa0>
view: <SimpleViewletClass from /home/_thet/data/dev/agitator/sfama.buildout/srccore/Products.CMFPlone/Products/CMFPlone/resources/browser/styles.pt plone.resourceregistries.styles at 0x7f2d1441c310>
translate: <function translate at 0x7f2d14329de8>
root: <ImplicitAcquisitionWrapper Zope at 0x7f2d18836190>
options: {...} (0)
target_language: <NoneType - at 0x5586dfe28560>
@agitator patched it with:
<configure
xmlns="http://namespaces.zope.org/zope"
xmlns:monkey="http://namespaces.plone.org/monkey"
i18n_domain="collective.monkeypatcher">
<include package="collective.monkeypatcher" />
<monkey:patch
description="Allow url(++ in style urls."
class="scss.grammar.scanner.Scanner"
original="_scan"
replacement=".patches.patchedScan"
/>
</configure>
and
# -*- coding: utf-8 -*-
from scss.errors import SassSyntaxError
DEBUG = False
# Allow url(++ in style urls
def patchedScan(self, restrict):
"""
Should scan another token and add it to the list, self.tokens,
and add the restriction to self.restrictions
"""
# Keep looking for a token, ignoring any in self.ignore
if DEBUG:
print()
print("Being asked to match with restriction:", repr(restrict))
token = None
while True:
best_pat = None
# Search the patterns for a match, with earlier
# tokens in the list having preference
best_pat_len = 0
for tok, regex in self.patterns:
if 'url(++' in self.input:
self.input = self.input.replace('url(++', 'url("++').replace(')', '")')
if DEBUG:
print("\tTrying %s: %s at pos %d -> %s" % (repr(tok), repr(regex.pattern), self.pos, repr(self.input)))
# First check to see if we're restricting to this token
if restrict and tok not in restrict and tok not in self.ignore:
if DEBUG:
print("\tSkipping %r!" % (tok,))
continue
m = regex.match(self.input, self.pos)
if m:
# We got a match
best_pat = tok
best_pat_len = len(m.group(0))
if DEBUG:
print("Match OK! %s: %s at pos %d" % (repr(tok), repr(regex.pattern), self.pos))
break
# If we didn't find anything, raise an error
if best_pat is None:
raise SassSyntaxError(self.input, self.pos, restrict)
# If we found something that isn't to be ignored, return it
if best_pat in self.ignore:
# This token should be ignored...
self.pos += best_pat_len
else:
end_pos = self.pos + best_pat_len
# Create a token with this data
token = (
self.pos,
end_pos,
best_pat,
self.input[self.pos:end_pos]
)
break
if token is not None:
self.pos = token[1]
# Only add this token if it's not in the list
# (to prevent looping)
if not self.tokens or token != self.tokens[-1]:
self.tokens.append(token)
self.restrictions.append(restrict)
return 1
return 0
but that fails for me with:
Traceback (most recent call last):
File "/home/_thet/data/dev/agitator/sfama.buildout/parts/instance/bin/interpreter", line 388, in <module>
exec(compile(__file__f.read(), __file__, "exec"))
File "/home/_thet/repos-config/dotfiles-thet/dot.buildout/eggs/Zope2-2.13.26-py2.7.egg/Zope2/Startup/run.py", line 76, in <module>
run()
File "/home/_thet/repos-config/dotfiles-thet/dot.buildout/eggs/Zope2-2.13.26-py2.7.egg/Zope2/Startup/run.py", line 22, in run
starter.prepare()
File "/home/_thet/repos-config/dotfiles-thet/dot.buildout/eggs/Zope2-2.13.26-py2.7.egg/Zope2/Startup/__init__.py", line 92, in prepare
self.startZope()
File "/home/_thet/repos-config/dotfiles-thet/dot.buildout/eggs/Zope2-2.13.26-py2.7.egg/Zope2/Startup/__init__.py", line 268, in startZope
Zope2.startup()
File "/home/_thet/repos-config/dotfiles-thet/dot.buildout/eggs/Zope2-2.13.26-py2.7.egg/Zope2/__init__.py", line 47, in startup
_startup()
File "/home/_thet/repos-config/dotfiles-thet/dot.buildout/eggs/Zope2-2.13.26-py2.7.egg/Zope2/App/startup.py", line 120, in startup
load_zcml()
File "/home/_thet/repos-config/dotfiles-thet/dot.buildout/eggs/Zope2-2.13.26-py2.7.egg/Zope2/App/startup.py", line 52, in load_zcml
load_site()
File "/home/_thet/repos-config/dotfiles-thet/dot.buildout/eggs/Zope2-2.13.26-py2.7.egg/Zope2/App/zcml.py", line 46, in load_site
_context = xmlconfig.file(site_zcml)
File "/home/_thet/repos-config/dotfiles-thet/dot.buildout/eggs/zope.configuration-3.7.4-py2.7.egg/zope/configuration/xmlconfig.py", line 649, in file
include(context, name, package)
File "/home/_thet/repos-config/dotfiles-thet/dot.buildout/eggs/zope.configuration-3.7.4-py2.7.egg/zope/configuration/xmlconfig.py", line 548, in include
processxmlfile(f, context)
File "/home/_thet/repos-config/dotfiles-thet/dot.buildout/eggs/zope.configuration-3.7.4-py2.7.egg/zope/configuration/xmlconfig.py", line 380, in processxmlfile
parser.parse(src)
File "/usr/lib/python2.7/xml/sax/expatreader.py", line 111, in parse
xmlreader.IncrementalParser.parse(self, source)
File "/usr/lib/python2.7/xml/sax/xmlreader.py", line 123, in parse
self.feed(buffer)
File "/usr/lib/python2.7/xml/sax/expatreader.py", line 220, in feed
self._parser.Parse(data, isFinal)
File "/usr/lib/python2.7/xml/sax/expatreader.py", line 384, in end_element_ns
self._cont_handler.endElementNS(pair, None)
File "/home/_thet/repos-config/dotfiles-thet/dot.buildout/eggs/zope.configuration-3.7.4-py2.7.egg/zope/configuration/xmlconfig.py", line 359, in endElementNS
self.context.end()
File "/home/_thet/repos-config/dotfiles-thet/dot.buildout/eggs/zope.configuration-3.7.4-py2.7.egg/zope/configuration/config.py", line 558, in end
self.stack.pop().finish()
File "/home/_thet/repos-config/dotfiles-thet/dot.buildout/eggs/zope.configuration-3.7.4-py2.7.egg/zope/configuration/config.py", line 706, in finish
actions = self.handler(context, **args)
File "/home/_thet/repos-config/dotfiles-thet/dot.buildout/eggs/zope.configuration-3.7.4-py2.7.egg/zope/configuration/xmlconfig.py", line 548, in include
processxmlfile(f, context)
File "/home/_thet/repos-config/dotfiles-thet/dot.buildout/eggs/zope.configuration-3.7.4-py2.7.egg/zope/configuration/xmlconfig.py", line 380, in processxmlfile
parser.parse(src)
File "/usr/lib/python2.7/xml/sax/expatreader.py", line 111, in parse
xmlreader.IncrementalParser.parse(self, source)
File "/usr/lib/python2.7/xml/sax/xmlreader.py", line 123, in parse
self.feed(buffer)
File "/usr/lib/python2.7/xml/sax/expatreader.py", line 220, in feed
self._parser.Parse(data, isFinal)
File "/usr/lib/python2.7/xml/sax/expatreader.py", line 384, in end_element_ns
self._cont_handler.endElementNS(pair, None)
File "/home/_thet/repos-config/dotfiles-thet/dot.buildout/eggs/zope.configuration-3.7.4-py2.7.egg/zope/configuration/xmlconfig.py", line 359, in endElementNS
self.context.end()
File "/home/_thet/repos-config/dotfiles-thet/dot.buildout/eggs/zope.configuration-3.7.4-py2.7.egg/zope/configuration/config.py", line 558, in end
self.stack.pop().finish()
File "/home/_thet/repos-config/dotfiles-thet/dot.buildout/eggs/zope.configuration-3.7.4-py2.7.egg/zope/configuration/config.py", line 706, in finish
actions = self.handler(context, **args)
File "/home/_thet/repos-config/dotfiles-thet/dot.buildout/eggs/zope.configuration-3.7.4-py2.7.egg/zope/configuration/xmlconfig.py", line 548, in include
processxmlfile(f, context)
File "/home/_thet/repos-config/dotfiles-thet/dot.buildout/eggs/zope.configuration-3.7.4-py2.7.egg/zope/configuration/xmlconfig.py", line 380, in processxmlfile
parser.parse(src)
File "/usr/lib/python2.7/xml/sax/expatreader.py", line 111, in parse
xmlreader.IncrementalParser.parse(self, source)
File "/usr/lib/python2.7/xml/sax/xmlreader.py", line 123, in parse
self.feed(buffer)
File "/usr/lib/python2.7/xml/sax/expatreader.py", line 220, in feed
self._parser.Parse(data, isFinal)
File "/usr/lib/python2.7/xml/sax/expatreader.py", line 384, in end_element_ns
self._cont_handler.endElementNS(pair, None)
File "/home/_thet/repos-config/dotfiles-thet/dot.buildout/eggs/zope.configuration-3.7.4-py2.7.egg/zope/configuration/xmlconfig.py", line 359, in endElementNS
self.context.end()
File "/home/_thet/repos-config/dotfiles-thet/dot.buildout/eggs/zope.configuration-3.7.4-py2.7.egg/zope/configuration/config.py", line 558, in end
self.stack.pop().finish()
File "/home/_thet/repos-config/dotfiles-thet/dot.buildout/eggs/zope.configuration-3.7.4-py2.7.egg/zope/configuration/config.py", line 706, in finish
actions = self.handler(context, **args)
File "/home/_thet/repos-config/dotfiles-thet/dot.buildout/eggs/zope.configuration-3.7.4-py2.7.egg/zope/configuration/xmlconfig.py", line 548, in include
processxmlfile(f, context)
File "/home/_thet/repos-config/dotfiles-thet/dot.buildout/eggs/zope.configuration-3.7.4-py2.7.egg/zope/configuration/xmlconfig.py", line 380, in processxmlfile
parser.parse(src)
File "/usr/lib/python2.7/xml/sax/expatreader.py", line 111, in parse
xmlreader.IncrementalParser.parse(self, source)
File "/usr/lib/python2.7/xml/sax/xmlreader.py", line 123, in parse
self.feed(buffer)
File "/usr/lib/python2.7/xml/sax/expatreader.py", line 220, in feed
self._parser.Parse(data, isFinal)
File "/usr/lib/python2.7/xml/sax/expatreader.py", line 384, in end_element_ns
self._cont_handler.endElementNS(pair, None)
File "/home/_thet/repos-config/dotfiles-thet/dot.buildout/eggs/zope.configuration-3.7.4-py2.7.egg/zope/configuration/xmlconfig.py", line 359, in endElementNS
self.context.end()
File "/home/_thet/repos-config/dotfiles-thet/dot.buildout/eggs/zope.configuration-3.7.4-py2.7.egg/zope/configuration/config.py", line 558, in end
self.stack.pop().finish()
File "/home/_thet/repos-config/dotfiles-thet/dot.buildout/eggs/zope.configuration-3.7.4-py2.7.egg/zope/configuration/config.py", line 706, in finish
actions = self.handler(context, **args)
File "/home/_thet/repos-config/dotfiles-thet/dot.buildout/eggs/collective.monkeypatcher-1.1.2-py2.7.egg/collective/monkeypatcher/meta.py", line 58, in replace
raise ConfigurationError("Original %s in %s not found" % (original, str(scope)))
zope.configuration.xmlconfig.ZopeXMLConfigurationError: File "/home/_thet/data/dev/agitator/sfama.buildout/parts/instance/etc/site.zcml", line 15.2-15.55
ZopeXMLConfigurationError: File "/home/_thet/data/dev/agitator/sfama.buildout/parts/instance/etc/package-includes/002-sfama.site-configure.zcml", line 1.0-1.54
ZopeXMLConfigurationError: File "/home/_thet/data/dev/agitator/sfama.buildout/srcsfama/sfama.site/src/sfama/site/configure.zcml", line 20.2-20.33
ZopeXMLConfigurationError: File "/home/_thet/data/dev/agitator/sfama.buildout/srcsfama/sfama.site/src/sfama/site/patches.zcml", line 8.4-13.10
ConfigurationError: Original _scan in <type 'scss.Scanner'> not found
Because my _scanner.so doesn't have the _scan method, while the fallback does.
I close the issue, because it addresses a Plone version that is no longer supported. If you think this is wrong please reopen the issue and assign a matching milestone.
Since the merge of https://github.com/plone/Products.CMFPlone/pull/2107 cooking/building css seems to be a lot stricter.
It looks like there is a problem if the src within an url() doesn't have quotes around.
I patched the scan method in https://github.com/Kronuz/pyScss/blob/master/scss/grammar/scanner.py#L202 with
Looks like that helps.
fyi collective.z3cform is there because I'm upgrading a site and will be gone after that. But there are a lot of addons that probably use the same unquoted resource url.
So where should this "enhancement" go within Plone?