您将python注册为内容对象上的Views:
<browser:page
for="**INTERFACE**"
name="**name**"
class="**class**"
attribute="**method**"
permission="zope2.View"
/>
Run Code Online (Sandbox Code Playgroud)
其中INTERFACE是您想要查看的对象的接口,
name是视图名称(即http://path-to-object/@@name),
class是定义脚本的Python类,属性是类的可选方法(默认为__ 调用 __).严格来说,我认为class是任何可调用的,不一定是类的方法.
这是我用于kss操作的脚本(与编写自己的AJAX脚本几乎相同) - 您的类可能需要从BrowserView继承(PloneKSSView是KSS视图的专用):
<browser:page
for="Products.VirtualDataCentre.interfaces.IDDCode"
name="getTableColumns"
class="Products.VirtualDataCentre.browser.DDActions.DDActions"
attribute="getTableColumns"
permission="zope2.View"
/>
Run Code Online (Sandbox Code Playgroud)
其中IDDCode是我需要视图的内容类型,DDActions.py具有:
from Products.Five import BrowserView
from plone.app.kss.plonekssview import PloneKSSView
class DDActions(PloneKSSView):
def getTableColumns(self, table, currValue, currLabel):
columns = self.context.getColumnNames(table)
for (field, curr) in [('valueColumn', currValue), ('labelColumn',currLabel)]:
self.replaceSelect(field, columns, (curr or self.context[field]))
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
543 次 |
| 最近记录: |