Debug and test Plomino applications
How to find why a formula is not working as expected.
Plomino debug mode
In Plomino, there is a debug mode (go to db, edit, then check Debug mode), it just enables a verbose mode, so you get more information in the Zope server log.
Plone debug practices
But basically you can use all the Plone dev tools and good practices:
Clouseau
Since Plomino 1.8, Clouseau is integrated in Plomino. If Clouseau is installed and enabled, the user can launch an online prompt to debug any failing formula.
Traces in the log
You can add some traces like this:
plominoDocument.plone_log("My value is:"+plominoDocument.the_value)
it will be displayed in the Zope log.
Zope in debug mode
You can launch your Zope instance in debug mode (non HTTP):
bin/instance debug
you get a python prompt where 'app' is the Zope application (so app.Plone.yourdb will be your db object). (Note that currently in debug mode, plominoDocument.plone_log will raise an AttributeError. So remove logging before executing formulas in a debug session.)
ZDB
Install zdb (see https://secure.simplistix.co.uk/svn/Simplistix/zdb/trunk/readme.txt), then insert this line in any Plomino formula:
from Products.zdb import set_trace; set_trace()
and when the formula is executed, you will be in debug mode in your server console.
Note: ZDB is an old product, but it does work, and is very useful.
Testing
You can create some Selenium tests to validate a behaviour and make sure it is not impacted by further changes.
You can create some python doctests (you can export your Plomino db as xml and have a doctest able to import it automatically in a blank site and run some tests, example: https://plomino.svn.sourceforge.net/svnroot/plomino/trunk/Plomino/Products/CMFPlomino/tests/samples.txt
(that is what we use in our buildbot to run the Plomino continuous testing).
Python introspection
in Python you can do:
>>> dir(obj)
it returns all the object methods (which can be a bit much for Plone objects with deep inheritance trees);
>>> obj.__dict__
it returns all the attributes as a dictionary;
>>> obj.__class__
it returns the class;
>>> hasattr(obj, "something")
tests if the object has an attribute or method named "something" ("something" may be found via acquisition; if you don't want acquisition, use shasattr from Products/Archetypes/utils.py).
So you can try that on any Plomino objects in a Clouseau session.

