Only compute formulas in the context of a document
Brought to you by:
ebrehault
Most formulas refer to `plominoDocument`, and when there is no document, this is None.
This and other factors leads to a lot of noise in the log when viewing a form directly.
Viewing a form could also have side effects if formulas are executed.
I propose not evaluating any formulas if a form is viewed outside of the context of a document.
After thinking some more ..
When you view a form with no document, it may be because you want to create a new document, and field formulas may need to execute in order to create default field values.
That means that field formulas should always be written to cope with the case that plominoDocument is None.
The document argument to `displayDocument` can be None, in which case plominoDocument is None, and plominoDocument = plominoContext
So the shortest way to find out that we're not in the context of a document is:
"""
if not plominoDocument or plominoDocument.isNewDocument():
return value-when-no-document
"""
That's a bit unwieldy if you do it often. I propose adding to PlominoUtils:
"""
def isDocument(doc):
return not doc or doc.isNewDocument()
"""