为betahaus.openmember导出
betahaus.exports.openmember的Python项目详细描述
简介
用于betahaus.openmember的扩展包 将搜索和完整数据库导出到cvs。它还支持注册自己的出口商。
扩展
可以扩展到海关出口商。您需要一个适配器和一个浏览器视图
适配器是通过创建继承自betahaus.exports.openmember.interfaces.iexporter的接口创建的 接口。
>>> from betahaus.exports.openmember.interfaces import IExporter >>> class IExportCustomAdapter(IExporter): ... """ Interface for registering custom exporter"""
使用实现适配器接口的代码。
>>> from betahaus.exports.openmember.browser.export import make_url >>> class ExportCustomAdapter(object): ... """Another exporter""" ... implements(IExportCustomAdapter) ... adapts(IExportable) ... ... def __init__(self, context): ... self.context = context ... ... def url(self): ... return '%s/custom_exporter%s' % (self.context.portal_url(), make_url(self.context.request)) ... ... def Title(self): ... return _('Custom Export from table')
然后,需要通过以下方式注册为出口商:
>>> registerExporter(IExportContactsAdapter)
我们还需要一些zcml来注册适配器,因为适配器中定义了所有内容,所以我们只需要:
<;adapter factory=“.export.exportcustomadapter”/>;
假设文件名为export.py
现在我们只需要一个浏览器视图来处理导出操作
>>> from betahaus.exports.openmember.browser.export import ExportBase >>> class ExportCustom(ExportBase): ... """Download as csv""" ... ... def __call__(self): ... # here you can do the changes that you need to do for your custom exporter.
有关可用功能的更多信息,请查看exportbase。
更改日志
0.1b2(2010-04-16)
- 修复了完整数据库csv导出的错误。[墙]
- 从操作中更新了导出程序的加载。[墙]
0.1b(2010-02-10)
- 初始版本