[Zope3-Users] configure.zcml entries for using adapters.
Stephan Richter
srichter at cosmos.phy.tufts.edu
Sat Nov 12 08:09:01 EST 2005
On Thursday 10 November 2005 19:55, John Smith wrote:
> I then created a nice page template which contains
> this snippet:
>
> <div tal:content="python:context.getTotalDistance()"
> />
>
> where context is the Car object.
This is wrong, because Car does not have a function called getTotalDistance.
In the view class do:
class View:
def getTotalDistance(self):
total = interfaces.IDistanceTotal(self.context)
return total.getTotalDistance()
In the view do:
<div tal:content="view/getTotalDistance" />
Note that you should never ever put a python call into your template.
Regards,
Stephan
--
Stephan Richter
CBU Physics & Chemistry (B.S.) / Tufts Physics (Ph.D. student)
Web2k - Web Software Design, Development and Training
More information about the Zope3-users
mailing list