[Zope-CMF] Re: Method Aliases

Yuppie schubbe at web.de
Tue Sep 30 04:05:35 EDT 2003


Hi!


Shane Hathaway wrote:
> In more ways than one!  Never use "is" with strings.  Here is one way it 
> fails:
> 
>  >>> str(u'a') is 'a'
> False

I see. Fixed.

> Also, I think that while method aliases are a good idea, implementing 
> them with a traversal hack is a bad idea.  It will kill whatever 
> performance we have left after all the other hacks we've done.  It's 
> shoehorning too much into Zope 2.

Before implementing it this way a did some profiling using the 
ZopeProfiler product. Maybe I did it wrong, but these were my results:

cumulative CPU cost:

   __before_publishing_traverse__  between 1 and 2 percents

   _getViewFor (used by __call__ and view) about 1 percent

if you use Method Aliases to bypass __call__() and view(), the overall 
cost is about 1 percent performance loss.

That's not for free, but I can't see why this should be a performance 
killer.

> The more interesting thing to do is to make something acquired from the 
> root of the portal that dispatches to skin methods based on the type of 
> the context.  For example, if we want an "edit" method alias, we might 
> create a skin method called "edit" that dispatches to "document_edit" if 
> it's applied to a document, "news_edit" for news, etc.  We could 
> continue to use the existing machinery for setting up aliases, but we 
> wouldn't use a traversal hook.

I'm not sure what you propose: All content objects have 'view', 'edit' 
and a default method. How would you override them using acquisition?


Cheers,
Yuppie





More information about the Zope-CMF mailing list