You register your python as Views on the content object:
<browser:page
for="**INTERFACE**"
name="**name**"
class="**class**"
attribute="**method**"
permission="zope2.View"
/>
Where INTERFACE is an interface of the object you want to have the view of,
name is the view name (ie, http://path-to-object/@@name
),
class is the Python class where your script is defined, and attribute is an optional method of the class (it defaults to __call__). Strictly, I think class is any callable, not necessarily a method of a class.
This is a script I use for a kss action (pretty much the same thing as writing your own AJAX scripts) - your class may need to inherit from BrowserView (PloneKSSView is a specialization of that for KSS views):
<browser:page
for="Products.VirtualDataCentre.interfaces.IDDCode"
name="getTableColumns"
class="Products.VirtualDataCentre.browser.DDActions.DDActions"
attribute="getTableColumns"
permission="zope2.View"
/>
where IDDCode is the content type on which I need the view, and DDActions.py has:
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]))