whenever adding a richtextfield to your custom type, you need to double check if the field isn't None, before getting its raw or output (relative or not - doesn't matter) value.
i guess this would be fixed by initiating richtextvalue even if its content is and empty (unicode-)string.
is there anything horribly wrong by following this approach?
is it hard to achieve?
would it break anything into pieces?
If your view extends from plone.dexterity.browser.view import DefaultView then you can use <div tal:content="structure view/w/details/render" /> in your template, which should handle this automatically.
Side note: you could add a default value (empty string), which should give you a RichTextValue be it empty.
Now I'm not sure what happens if you have an optional field. Optional fields in zope schema land will give you a None for any field, so you need to check for that.
maybe i did not explain it correct, but you are talking about the template and that only.
i am seeking and proposing a solution for python and templates.
@default-value
this is exactly where i stumbled for example:
having richtext with a value and then emptying it - store that and you get "None" and have to check for the values very carefully.
you could be more carefree, when a richtext is a richtext, no matter, if empty or filled with whatever.
@widget
define="value view/value"
condition="nocall:value"
content="structure python:value.output_relative_to(view.context)"
the holy trinity of questions to get text displayed - i know that
but what about that once and for all:
define="value python:value.output_relative_to(view.context)"
condition="value"
or in python
if value and value.output_relative_to(view.context):
...
vs
if value.output_relative_to(view.context):
...
i actually don't like to ask a richtext to be richtext in order to do richtext stuff with it.
but maybe its a wish from z3c.form to have to ask that.
on a generic field i'd understand that for sure.