[Zope3-Users] configure.zcml entries for using adapters.
John Smith
jsmith030416 at yahoo.co.uk
Thu Nov 10 19:55:23 EST 2005
I have a content component called 'journey' which
provides three attributes:
journey_description, journey_date, and
distance_travelled.
These 'journey' objects live in a container called
'car'. A car has attributes like owner, registration
etc.
So far, Everything is fine.
I thought I would try to use adapters to extend the
functionality of a 'car' object so that in the
zmi_views, I could have a 'totals' page, showing the
sum of the distance_travelled attributes of all the
car's journey objects.
I created an interface for the adapter, IDistanceTotal
which describes one method, getTotalDistance. I
created and adapter class, CarTotalDistanceAdapter. I
updated configure.zcml like this:
<adapter
for=".interfaces.ICar"
factory=".adapters.CarTotalDistanceAdapter"
provides=".interfaces.IDistanceTotal"
/>
I tested the correct operation of the adapter in
accordance with:
Zope 3 Developer's Handbook,p142 and also with Web
Component Development with Zope 3, page 149. The
adapter was recognized, the getTotalDistance method
appeared as an attribute of the Car object and valid
results appeared for the distance travelled.
I then created a nice page template which contains
this snippet:
<div tal:content="python:context.getTotalDistance()"
/>
where context is the Car object.
Now, here is my problem: no matter what I do in the
configure.zcml file, I cannot seem to get the context
object to pick up the getTotalDistance method from the
adapter. Depending on the security/permissions
settings I either see: forbidden attribute or not
found errors.
I have tried studying the code of the zwiki product
but to no avail.
Am I right in thinking that my problems are related to
the configure.zcml file? Any pointers gratefully
received.
I can get the ISized examples from the books to work
ok.
Thanks to all.
John
___________________________________________________________
To help you stay safe and secure online, we've developed the all new Yahoo! Security Centre. http://uk.security.yahoo.com
More information about the Zope3-users
mailing list