[Zope3-dev] Re: ContextMethods

Jim Fulton jim@zope.com
Tue, 08 Jul 2003 16:27:37 -0400


Garrett Smith wrote:
> When should a method be defined as a ContextMethod?

I would hope almost never.

A method needs to be a context method when it needs it's
"self" argument to be context wrapped. This will be the case
when it needs to pass self to any component architecture apis
(e.g. to look up a service or other kind of component.)

It's rare for content methods to need to do these things, because
they rarely have application logic in them. Typically views and
adapters created by views need access to context.  Views and
adapters typically access context through their context attributes,
which are typically context wrapped.

Jim


-- 
Jim Fulton           mailto:jim@zope.com       Python Powered!
CTO                  (703) 361-1714            http://www.python.org
Zope Corporation     http://www.zope.com       http://www.zope.org