Mosaic in Plone 5.2 with custom theme (not barceloneta)

Hi

I am trying to upgrade some themes to Plone 5.2
When using Mosaic, I get the following error (See below).
This even happens if I replace my rules.xml and index.html with those from barceloneta.

If I duplicate barceloneta TTW, it works.
If I change to barceloneta and save a mosaic layout, it works (even when this is identical to the 'default.html' layout.
If I change to barceloneta and enable mosaic layout and save, I can enable my theme and edit the page without any errors.

Any ideas ?

    2019-08-05 12:28:07,917 ERROR   [plone.transformchain:70][waitress] Unexpected error whilst trying to apply transform chain
Traceback (most recent call last):
  File "/Users/rolf/Plone52/buildout-cache/eggs/plone.transformchain-2.0.1-py2.7.egg/plone/transformchain/transformer.py", line 59, in __call__
    newResult = handler.transformIterable(result, encoding)
  File "/Users/rolf/Plone52/buildout-cache/eggs/plone.app.theming-4.0.1-py2.7.egg/plone/app/theming/transform.py", line 176, in transformIterable
    cache
  File "/Users/rolf/Plone52/buildout-cache/eggs/plone.app.theming-4.0.1-py2.7.egg/plone/app/theming/utils.py", line 698, in prepareThemeParameters
    params[name] = quote_param(expression(expressionContext))
  File "/Users/rolf/Plone52/buildout-cache/eggs/Zope-4.1.1-py2.7.egg/Products/PageTemplates/ZRPythonExpr.py", line 49, in __call__
    return eval(self._code, vars, {})
  File "PythonExpr", line 1, in <module>
AttributeError: 'FilesystemResourceDirectory' object has no attribute 'portal_registry'
2019-08-05 12:28:07,924 WARNING [waitress:498][waitress] application returned too few bytes (0) for specified Content-Length (1059) via app_iter

not sure if this is of any help:

(Pdb) self._globals

{'_iter_unpack_sequence_': <function guarded_iter_unpack_sequence at 0x109947938>,
'__metaclass__': <function _metaclass at 0x1099c0140>,
'sequence': <module 'DocumentTemplate.sequence' from '/Users/rolf/Plone52/buildout-cache/eggs/DocumentTemplate-3.1b2-py2.7.egg/DocumentTemplate/sequence/__init__.pyc'>,
'__builtins__': {'all': <function guarded_all at 0x1099c00c8>,
'BytesWarning': <type 'exceptions.BytesWarning'>,
'pow': <built-in function pow>,
'RuntimeError': <type 'exceptions.RuntimeError'>,
'float': <type 'float'>,
'MemoryError': <type 'exceptions.MemoryError'>,
'_getattr_': <function safer_getattr at 0x1099478c0>,
'DateTime': <class 'DateTime.DateTime.DateTime'>,
'StopIteration': <type 'exceptions.StopIteration'>,
'divmod': <built-in function divmod>,
'unicode': <type 'unicode'>,
'enumerate': <function guarded_enumerate at 0x1099bfb90>,
'apply': <function builtin_guarded_apply at 0x1099bff50>,
'isinstance': <built-in function isinstance>,
'same_type': <function same_type at 0x109947c08>,
'basestring': <type 'basestring'>,
'UnicodeError': <type 'exceptions.UnicodeError'>,
'zip': <function guarded_zip at 0x1099bfaa0>,
'LookupError': <type 'exceptions.LookupError'>,
'hex': <built-in function hex>,
'long': <type 'long'>,
'IndentationError': <type 'exceptions.IndentationError'>,
'NameError': <type 'exceptions.NameError'>,
'ImportError': <type 'exceptions.ImportError'>,
'chr': <built-in function chr>,
'complex': <type 'complex'>,
'dict': <AccessControl.ZopeGuards.GuardedDictType instance at 0x1099a76c8>,
'__import__': <function guarded_import at 0x1099bfb18>,
'IOError': <type 'exceptions.IOError'>,
'oct': <built-in function oct>,
'reorder': <function reorder at 0x1099652a8>,
'SystemExit': <type 'exceptions.SystemExit'>,
'Exception': <type 'exceptions.Exception'>,
'random': <module 'random' from '/usr/local/Cellar/python/2.7.13_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/random.pyc'>,
'string': <module 'string' from '/usr/local/Cellar/python/2.7.13_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/string.pyc'>,
'StandardError': <type 'exceptions.StandardError'>,
'tuple': <type 'tuple'>,
'reduce': <function guarded_reduce at 0x1099bf8c0>,
'repr': <built-in function repr>,
'next': <function guarded_next at 0x1099bf410>,
'UnicodeEncodeError': <type 'exceptions.UnicodeEncodeError'>,
'UnicodeDecodeError': <type 'exceptions.UnicodeDecodeError'>,
'hasattr': <function guarded_hasattr at 0x1099bf050>,
'delattr': <function guarded_delattr at 0x109947848>,
'IndexError': <type 'exceptions.IndexError'>,
'RuntimeWarning': <type 'exceptions.RuntimeWarning'>,
'setattr': <function guarded_setattr at 0x109947578>,
'list': <AccessControl.ZopeGuards.GuardedListType instance at 0x1099a7680>,
'SyntaxWarning': <type 'exceptions.SyntaxWarning'>,
'iter': <function guarded_iter at 0x1099bf758>,
'whrandom': <module 'random' from '/usr/local/Cellar/python/2.7.13_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/random.pyc'>,
'ArithmeticError': <type 'exceptions.ArithmeticError'>,
'Warning': <type 'exceptions.Warning'>,
'math': <module 'math' from '/Users/rolf/Plone52/zinstance/lib/python2.7/lib-dynload/math.so'>,
'str': <type 'str'>,
'round': <built-in function round>,
'cmp': <built-in function cmp>,
'False': False,
'GeneratorExit': <type 'exceptions.GeneratorExit'>,
'set': <type 'set'>,
'int': <type 'int'>,
'xrange': <type 'xrange'>,
'UnicodeTranslateError': <type 'exceptions.UnicodeTranslateError'>,
'KeyError': <type 'exceptions.KeyError'>,
'PendingDeprecationWarning': <type 'exceptions.PendingDeprecationWarning'>,
'issubclass': <built-in function issubclass>,
'EnvironmentError': <type 'exceptions.EnvironmentError'>,
'unichr': <built-in function unichr>,
'id': <built-in function id>,
'BufferError': <type 'exceptions.BufferError'>,
'slice': <type 'slice'>,
'DeprecationWarning': <type 'exceptions.DeprecationWarning'>,
'min': <function guarded_min at 0x1099bf9b0>,
'FloatingPointError': <type 'exceptions.FloatingPointError'>,
'UnicodeWarning': <type 'exceptions.UnicodeWarning'>,
'sum': <function guarded_sum at 0x1099bfde8>,
'AttributeError': <type 'exceptions.AttributeError'>,
'any': <function guarded_any at 0x1099c0050>,
'getattr': <built-in function guarded_getattr>,
'abs': <built-in function abs>,
'bool': <type 'bool'>,
'test': <function test at 0x10994d9b0>,
'True': True,
'ValueError': <type 'exceptions.ValueError'>,
'FutureWarning': <type 'exceptions.FutureWarning'>,
'ImportWarning': <type 'exceptions.ImportWarning'>,
'map': <function guarded_map at 0x1099bfa28>,
'None': None,
'hash': <built-in function hash>,
'max': <function guarded_max at 0x1099bf938>,
'len': <built-in function len>,
'TabError': <type 'exceptions.TabError'>,
'callable': <built-in function callable>,
'SyntaxError': <type 'exceptions.SyntaxError'>,
'OSError': <type 'exceptions.OSError'>,
'frozenset': <type 'frozenset'>,
'ord': <built-in function ord>,
'ReferenceError': <type 'exceptions.ReferenceError'>,
'AssertionError': <type 'exceptions.AssertionError'>,
'TypeError': <type 'exceptions.TypeError'>,
'KeyboardInterrupt': <type 'exceptions.KeyboardInterrupt'>,
'UserWarning': <type 'exceptions.UserWarning'>,
'ZeroDivisionError': <type 'exceptions.ZeroDivisionError'>,
'UnboundLocalError': <type 'exceptions.UnboundLocalError'>,
'filter': <function guarded_filter at 0x1099bf848>,
'range': <built-in function range>,
'EOFError': <type 'exceptions.EOFError'>,
'NotImplementedError': <type 'exceptions.NotImplementedError'>,
'SystemError': <type 'exceptions.SystemError'>,
'OverflowError': <type 'exceptions.OverflowError'>,
'BaseException': <type 'exceptions.BaseException'>},
'_apply_': <function guarded_apply at 0x1099bfed8>,
'_write_': <function guard at 0x109947500>,
'_print_': <class 'RestrictedPython.PrintCollector.PrintCollector'>,
'_getattr_': <built-in function guarded_getattr>,
'_inplacevar_': <function protected_inplacevar at 0x1099c0758>,
'_getiter_': <function guarded_iter at 0x1099bf758>,
'__debug__': True,
'_getitem_': <function guarded_getitem at 0x1099bf0c8>,
'_unpack_sequence_': <function guarded_unpack_sequence at 0x1099479b0>}
(Pdb) > /Users/rolf/Plone52/buildout-cache/eggs/Zope-4.1.1-py2.7.egg/Products/PageTemplates/ZRPythonExpr.py(47)__call__()

Not sure what your theme is based on but mosaic depends at least on some barceloneta resources https://github.com/plone/plone.app.mosaic/blob/master/src/plone/app/mosaic/browser/static/css/mosaic.grid.less#L2

When I used the rules.xml and index.html (instead of my own), I also used the css from barceloneta (added it to the manifest.cfg file)

More inportant: If I make a new mosaic layout TTW, everything works.

For example, I can do this:

  1. Switch to barceloneta
  2. Add a new page, choose mosaic view, edit it
  3. Save (the unedited) view as a new mosaic layout
  4. Hide the other (mosaic) layout
  5. Switch back to my theme

After this, everything works as it should. Every new page can be set to Mosaic, edited and saved and viewed without any errors.

We are using multitheme and have come across the same error. We traced it to a python expression used in manifest.cfg

You were using:
fullwidth = python:context.portal_registry['IRegKeyExample']==True

We changed it to:
fullwidth = python:portal_state.portal().portal_registry['IRegKeyExample']==True

And the error is no longer happening. The context during execution was an FileSystemResourceDirectory object which of course does not have portal_registry

By this time you may have realized this as well but posting it here for others.

I have discontinued work on multitheme, but I assume it should still work OK, maybe also on 5.2.

Note: A 'fluid' option was added to Mosaic itself, so I removed the option (also in the commercial themes I make). At some point, the default Mosaic fluid stopped working 'as before', so basically I would say that the 'full width setting was useful and should not have been removed').

If so, you would be left with two settings for the same thing…

The multitheme approach is to have a 'toggle fullwidth', while Mosaic has toggle of 'fluid'.

PS: collective.multitheme is on GitHub, feel free to add it: GitHub - collective/collective.multitheme: A multi purpose Plone 5 theme for Mosaic and Themingfragments