[Zope3-Users] To Subclass, or to Adapt?
jamesallwyn at yahoo.co.uk
Mon Aug 15 06:03:56 EDT 2005
(order of quoted sections changed)
> >* Is is possible to access the output of an adapter
> >directly from ZPT?
> >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
> >viewclass, so it would be one less piece
> >of code to maintain.
> The view-layer definitly make sense, but sometimes
> it brings a certain
> implementation/registration overhead/burden.
Ah, I see it now - I think I had been working too long
on a Sunday! Of course my view class does mention the
adapter Interface, and becuase there is no easy way of
doing this in the ZPT, that's why the view class is
needed. Fair enough.
On your other suggestion:
> >My adapter provides a method getRating. I've
> >used the following to get it to also provide
> >this as a property:
> >rating = property(getRating)
> 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
I'm interested in the theory behind whether to provide
a method or a property from an adapter. I had
initially used a method, because I was following the
examples from the books (which are on the ISized
adapter, which provides two methods). Then I noticed
something along the lines of foo=property(getFoo) in
Stephan's book, which seemed to turn the getFoo method
into a foo property. Why is one better than the other?
Stephan seems to use it particularly when he has
getters and setters defined - in the case of my
ratings I think they will be calculated rather than
set, so would this lessen the relevance of the
providing a property rather than a method?
Yahoo! Messenger - NEW crystal clear PC to PC calling worldwide with voicemail http://uk.messenger.yahoo.com
More information about the Zope3-users