我可以在 Plone portlet 上使用 z3c.form 而不是 zope.formlib 吗?
考虑到我有一个普通的 ZopeSkel plone3_portlet formlib 生成的包,我需要进行哪些修改?即:
- 我应该从哪些类继承?
- 我必须提供哪些挂钩?
我可以一直使用它,包括 Five.grok 和 plone.directives.form 吗?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
是的,你可以做到这一点,你需要的是添加/编辑表单...这是我为 Jarn 项目所做的,你可以使用 AddForm 和 EditForm ,就像使用它们的 formlib 等效项一样:
Yes, you can do that, what you need is the Add/Edit forms... Here's what I did it for a Jarn project, you can use AddForm and EditForm the same way you would use their formlib equvalent:
开源 Collective.dancing.browser.portlets.channelsubscribe 模块具有以 z3c.form 编写的 Portlet 实现。
但这是一个巨大的混乱。我建议不要对 Plone portlet 做任何花哨的事情,因为它的复杂性会在你面前爆炸。
请参阅 http://dev。 plone.org/collective/browser/collective.dancing/trunk/collective/dancing/browser/portlets/channelsubscribe.py 或 http://pypi.python.org/pypi/collective.dancing
The open source collective.dancing.browser.portlets.channelsubscribe moudle has implementations of portlets written in z3c.form.
It's a huge mess though. I'd recommend against doing anything fancy with Plone portlets because of its complexity will blow up in your face big time.
See http://dev.plone.org/collective/browser/collective.dancing/trunk/collective/dancing/browser/portlets/channelsubscribe.py or http://pypi.python.org/pypi/collective.dancing
这当然是可以做到的。我们已经在 4.0 Plone 项目中使用了它,其中一位同事使用
z3c.form.form.AddForm
创建了基本的IPortletAddForm
和IPortletEditForm
实现,并且分别是z3c.form.form.EditForm
基类。请注意,这是 Plone 4.0,而不是 3.x,因此您的情况可能会有所不同。
该实现是对其 zope.formlib 原始版本的基本重新实现,使用简单的 buttonAndHandler 处理程序来处理“添加”(添加表单)、“保存”(编辑表单)和“取消”(两者)按钮。
我相信我们计划将基本表单实现贡献回 plone.app.portlets,我会询问他。
This certainly can be done. We already use this in a 4.0 Plone project, where a colleague created a base
IPortletAddForm
andIPortletEditForm
implementations usingz3c.form.form.AddForm
andz3c.form.form.EditForm
base classes respectively.Note that this is Plone 4.0, not 3.x, so your mileage may vary.
The implementation is a basic reimplementation of their zope.formlib originals, with simple buttonAndHandler handlers to handle the Add (add form), Save (edit form) and Cancel (both) buttons.
I believe we have plans to contribute the base form implementations back to plone.app.portlets, I'll ask him about it.
如果像我一样,您在 2 年后发现了这个问题,那么了解一下可能会很方便:
ggozad 的解决方案已集成到 plone.app.portlets
您仍然需要在他的解决方案(我的解决方案)之上编写 portlet
发现很难解决)
我已经整理了我的工作代码的变体
此处
除非您使用 Plone 5,否则您需要保留
plone.app.portlets < 3.0
非常感谢这个包的作者(注意这是在 ggozad 的解决方案集成到 plone.app.portlets 之前编写的)
If like me you've found this question 2 years later, then it might be handy to know that:
ggozad's solution has been integrated into plone.app.portlets
You still need to write the portlet on top of his solution (which I
found hard to work out)
I've put together a variation of my working code
here
Unless you are using Plone 5 you will need to keep
plone.app.portlets < 3.0
A lot of credit to the author of this package (note that this was written BEFORE ggozad's solution was integrated into plone.app.portlets)
我认为理论上是可能的,是的,但我不确定是否有人尝试过。这可能是我们在某一时刻需要在 Plone 中做的事情,所以如果你能成功让它发挥作用那就太好了。
我首先查看现有的 portlet 表单基类的作用,并尝试在 z3c.form 中模拟它。我现在也可能会在没有 plone.directives.form 和 plone.autoform 的情况下开始,因为这可能会让你有点困惑。最好稍后再添加。
我怀疑,主要的事情是为新表单注册一个新的默认模板,然后根据 plone.app.portlets 的基本表单为实际的“添加”和“编辑”操作添加一些挂钩。
I think it's theoretically possible, yes, but I'm not sure anyone's tried it. It's probably something we'll need to do in Plone at one point, so it'd be great if you managed to make it work.
I'd start by looking at what the existing portlet form base classes do and try to emulate that in z3c.form. I'd also probably start without plone.directives.form and plone.autoform for now, as that will probably confuse you a bit to start with. Better to add those later.
The main thing, I suspect, will be to register a new default template for the new forms, and then add some hooks for the actual "add" and "edit" operations as per plone.app.portlets's base forms.
我相信 David Glick 已经通过 Carousel 实现了这一点。他的文档指向已知-很好的一套,对我有用。
I believe that David Glick has accomplished this with Carousel. His documentation points to a known-good set that's worked for me.
我知道这是一个不完整的答案,但我相信它会为您指明正确的方向。 plonezohointegration 产品使用 z3cforms 作为其 portlet,您可以看看它是如何做到的。
有关于如何完成的文档 在 plone 社区开发者文档中
I know this is an incomplete answer, but I believe it will point you in the right direction. The plonezohointegration product uses z3cforms for its portlets you can look at how the did it.
There's documentation on how it is done in the plone community developer documentation