On one of my Plone sites, I have several dexterity patterns that I use to create letters. Models are: “Model” (the basic contents of the letter), “Contact” (which contains contact information, such as name, address, etc.) and “Combine” (which is the object of the model, which we substitute parts of the model with recipient information). The scheme of the Merge object is as follows:
class IMergeSchema(form.Schema):
"""
"""
title = schema.TextLine(
title=_p(u"Title"),
)
form.widget(text='plone.app.z3cform.wysiwyg.WysiwygFieldWidget')
text = schema.Text(
title=_p(u"Text"),
required=False,
)
form.widget(recipients=MultiContentTreeFieldWidget)
recipients = schema.List(
title=_('label_recipients',
default='Recipients'),
value_type=schema.Choice(
title=_('label_recipients',
default='Recipients'),
source=UUIDSourceBinder(portal_type='Contact')),
)
form.widget(model=ContentTreeFieldWidget)
form.mode(model='display')
model = schema.Choice(
title=_('label_model',
default='Model'),
source=UUIDSourceBinder(portal_type='Model'),
)
"" , "" , , .
, : http://plone.org/products/dexterity/documentation/manual/developer-manual/reference/default-value-validator-adaptors
, "". ( , ;)):
@form.default_value(field=IMergeSchema['recipients'])
def all_recipients(data):
contacts = [x for x in data.context.contentValues()
if IContact.providedBy(x)]
paths = [u'/'.join(c.getPhysicalPath()) for c in contacts]
uids = [IUUID(c, None) for c in contacts]
print 'Contacts: %s' % contacts
print 'Paths: %s' % paths
print 'UIDs: %s' % uids
return paths
, ( "self.widgets ['recipients'.] ", ) UID, .
, .
, .