sca*_*a05 5 behavior plone dexterity
我们要求灵活性内容类型排除导航行为,但要求exclude_from_nav字段的默认值True.在plone.app.dexterity.behaviors.exclfromnav.IExcludeFromNavigation默认的行为中False.
显然我可以创建自己的行为,IExcludeFromNavigation除了默认值以外的副本,但我想知道是否有办法在重用时执行此操作IExcludeFromNavigation.我们还有其他内容类型可以使用IExcludeFromNavigation我们希望默认使用的内容类型False.
我们正在使用Plone 4.1rc3和Dexterity 1.0
请参阅http://plone.org/products/dexterity/documentation/manual/developer-manual/advanced/defaults和http://pypi.python.org/pypi/plone.directives.form#value-adapters,但基本上:
@form.default_value(field=IExcludeFromNavigation['exclude_from_nav'], context=IMyType)
def excludeFromNavDefaultValue(data):
return True
Run Code Online (Sandbox Code Playgroud)
干杯,马丁
我使用plone.directives.form装饰器来完成这个工作。
我已将其添加到我的行为模块之一。
from plone.directives.form import default_value
@default_value(field = IExcludeFromNavigation['exclude_from_nav'])
def excludeFromNavDefaultValue(data):
return data.request.URL.endswith('++add++my_item_type')
Run Code Online (Sandbox Code Playgroud)
我在configure.zcml中还有以下内容
<include package="plone.directives.form" file="meta.zcml" />
<include package="plone.directives.form" />
<grok:grok package="." />
Run Code Online (Sandbox Code Playgroud)
感谢马丁提供的重要线索,尽管他的回答并没有完全解决我的问题。这对我来说有点像黑客 - 一个更优雅的解决方案会很好。
| 归档时间: |
|
| 查看次数: |
1306 次 |
| 最近记录: |