AFAIK 不是没有编码 :-)
创建新的 DataSaveAdapter 内容类型
最好的方法是从现有的继承并添加一个新字段:
from Products.PloneFormGen.content.saveDataAdapter import FormSaveDataAdapter
SendDataAdapterSchema = FormSaveDataAdapter.schema.copy() + atapi.Schema((
atapi.StringField(
name='csv_recipients',
required=False,
widget=atapi.LinesWidget(
label=_(u'label_csv_recipients', default=u'CSV recipients'),
)
)
))
class SendDataAdapter(FormSaveDataAdapter):
implements(IPloneFormGenActionAdapter)
...
schema = SendDataAdapterSchema
...
- SaveDataAdapter 提供了一种
onSuccess
方法,您可以在其中连接并发送电子邮件
class SendDataAdapter(FormSaveDataAdapter):
...
def onSuccess(self, fields, REQUEST=None, loopstop=False):
""" saves input data and initiates mail"""
super(SendDataAdapter, self).onSuccess(fields, REQUEST, loopstop)
self.send_csv() # This is where you may implement sending the email.
当然,它需要一些工作才能完成(注册内容类型等),但这应该为您指明正确的方向。