[Zope-CMF] Re: Method Aliases

Shane Hathaway shane at zope.com
Tue Sep 30 16:21:27 EDT 2003


Janko Hauser wrote:
> On the types with a view class there needs to be a __bobo_traverse__
> to catch the call of a method like doc/edit. Then we use something
> like getadapter to instantiate a view class and put these between the
> doc and its parent in the acquistion path. 
> 
> folder/doc/edit  --> folder/vc/doc/edit

What is vc?  Is it the name of a view, or is it some special object that 
causes ZPublisher to look up a view when it reaches the name "edit"?

> the edit() is now the method of the viewclass. All fine, although we
> actually want to have more than one view class for an object. Bad
> thing is, that, in order to not always write
> self.context.getsomedata() in the view class we need to overwrite
> __getattr__ in the view class, which is problematic. Actually it works
> but we would appreciate ideas for other approaches. Important is, that
> view class have only a lifetime of a request (perhaps later on a
> session) and are dynamically instantiated at the beginning of the
> request.

The Zope 3 mantra is "no more magic", so instead of a __getattr__ hook, 
Zope 3 would just use self.context.getsomedata().  It's cleaner that way.

Shane




More information about the Zope-CMF mailing list