=================
ZCML directives
=================
This package registers two new ZCML directives. These are:
-- used to register a new type of condition
-- used to register a new type of action
We have created a dummy condition and a dummy action in
plone.contentrules.rule.tests.elements. We haven't bothered to register an
addview or an edit view, but in real life we would need to do so using the
usual directives or similar.
Here is how we would register these in ZCML:
>>> zcml = """\
...
...
...
...
...
...
... """
>>> from zope.configuration.xmlconfig import xmlconfig
>>> from StringIO import StringIO
First, we need to make sure the ZCML directives are defined:
>>> from zope.configuration.xmlconfig import XMLConfig
>>> import plone.contentrules
>>> XMLConfig('meta.zcml', plone.contentrules)()
Then we process the ZCML string above:
>>> xmlconfig(StringIO(zcml))
The end result should be two new utilities. These can be used create and
inspect conditions and actions in rules.
>>> from plone.contentrules.rule.interfaces import IRuleCondition
>>> from plone.contentrules.rule.interfaces import IRuleAction
>>> from zope.component import getUtility
>>> from zope.component.interfaces import IObjectEvent
>>> from plone.contentrules.rule.tests import elements
>>> condition = getUtility(IRuleCondition, name=u"test.condition")
>>> condition.title
u'Test condition'
>>> condition.description
u'A test condition'
>>> condition.for_ == None
True
>>> condition.event == IObjectEvent
True
>>> condition.addview
u'test.condition'
>>> condition.editview
u'edit'
>>> condition.schema == elements.ITestCondition
True
>>> condition.factory == elements.TestCondition
True
>>> action = getUtility(IRuleAction, name=u"test.action")
>>> action.title
u'Test action'
>>> action.description
u'A test action'
>>> action.for_ == None
True
>>> action.event == IObjectEvent
True
>>> action.addview
u'test.action'
>>> action.editview
u'edit'
>>> action.schema == elements.ITestAction
True
>>> action.factory == elements.TestAction
True