James Allwyn wrote:

Thanks Stephan and Dominik for all the help so far.
I've decided to go down the route Stephan suggested,
since I was more able to get my head around it.

I've got a question about adapters / ZPT:

* Is is possible to access the output of an adapter
directly from ZPT?
There was such a proposal:

IMO only the IPathAdapter is implemented yet, but I'm not shure. I never used those features...

My adapter provides a method getRating. I've used the
following to get it to also provide this as a

rating = property(getRating)

which seems to work. At the moment I am having to use
view/rating in my ZPT; the view class can say either:

rating = self.rate.getRating()
rating = self.rate.rating

depending on whether I want to access the method or
the property - both seem to work OK.
Yes, but I would not offer both. I would limit the interface to the property only, because the property can used more easily generating generic view such as schemadisplay, add/editform and form...

However, I would
like to change from view/rating to context/rating or
context/getRating in the ZPT - this would seem cleaner
and more logical to me - I could do away with the view
class, so it would be one less piece of code to
The view-layer definitly make sense, but sometimes it brings a certain implementation/registration overhead/burden.

If you are to lazy to map your views manualy to your adapters or if you like to omit a lot of extra code, then you could use/ write generic views which can be registered using zcml-registrations.

In your case it might possible to use the schemadisplay directive, maybe you have to write an additional widget for the rating field and a custom template.

My understanding of the adapter is that it has adapted
my object so it now provides the getRating() method
and rating property of the adapter interface - it
would seem to me that this should mean I can access it
like any other method or property the object provides,
but it does not seem to be the case.
No, you have to adapt explicitly:
obj = object()
adaptedobject  = IRating(obj)
or any equivalent or extending zapi method for example getAdapter or getMultiAdapter


Zope3-users mailing list

Reply via email to