[Zope3-Users] To Subclass, or to Adapt?

James Allwyn jamesallwyn at yahoo.co.uk
Sun Aug 14 18:15:18 EDT 2005


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?

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

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()
or
rating = self.rate.rating

depending on whether I want to access the method or
the property - both seem to work OK. 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
maintain.

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.

Thanks,
James


--- Stephan Richter <srichter at cosmos.phy.tufts.edu>
wrote:

> On Thursday 11 August 2005 06:36, James Allwyn
> wrote:
> > If so, I guess we will be building an adapter
> along
> > similar lines to the size adapter both Stephan and
> > Phillip use as an example in their books - maybe
> > create an IRating interface, and create adapters
> for
> > each of the sub-classes to adapt those to IRating?
> 
> Yep.
> 
> Regards,
> Stephan
> -- 
> Stephan Richter
> CBU Physics & Chemistry (B.S.) / Tufts Physics
> (Ph.D. student)
> Web2k - Web Software Design, Development and
> Training
> 



		
___________________________________________________________ 
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