[Zope-CMF] [Optimization] "listFilteredActionsFor"
Dieter Maurer
dieter at handshake.de
Sat Apr 8 14:14:39 EDT 2006
Jens Vagelpohl wrote at 2006-4-8 11:07 +0100:
> ...
>On 2 Apr 2006, at 20:36, Dieter Maurer wrote:
>
>> Yuppie already has considerable sped up "listFilteredActionsFor"
>> for CMF 1.5. However, even after his optimizations
>> "listFilteredActionsFor"
>> can still consume lots of time.
>> I found simple situations where it had spend more then 10 percent of
>> total request time in "testCondition".
>>
>> I propose to make the category lists lazy objects that perform
>> condition and permission evaluation only when they are accessed.
>> This means that action categories not used on a specific page
>> would not have the expensive "testCondition" evaluated.
>
>Dieter,
>
>I'm sure you have some code samples or ideas for how to make that
>happen, right?
Up to now, I have only an idea:
"listFilteredActionsFor" returns a dictionary
"category --> list of available actions".
The list is currently a normal list, only available
actions are appended.
I want to replace this normal list by a lazy list.
All actions belonging to the given category are appended
to it, whether or not they are available.
The lazy list evaluates action availability as soon as
one of its "__len__", "__getitem__" or "__getslice__"
methods are called, filters out unavailable actions
and then behaves like a normal list.
The gain: actions in categories not used on the current page
are not checked for availability.
--
Dieter
More information about the Zope-CMF
mailing list