Message3565
The LinkHTMLProperty.menu() function does conceptually this:
---
options = [o for o in filter(spec) if permitted('View', o)]
for o in options:
add_menu_item(o)
---
This seemingly benign chunk of code may involve a lot of SQL calls:
* at least one SQL call inside the filter() call, then possible N more
in the N calls to permitted() (where N is the number of objects
returned by filter()
* N more SQL calls as add_menu_item() needs to fetch the label property
for each item.
So, 2N + 1 distinct SQL calls to fill a single menu with N options.
I believe at least some of this can be optimized:
1) With an enhanced version of filter(), not only matching nodeids would
be returned, but requested properties, too. This would get rid of the
SQL calls inside add_menu_item().
2) The permission checks could possibly be fused, too. However, as in
general permissions are handled outside SQL, this is much harder.
Therefor, I'd suggest to enhance filter() so instead of simply returning
matching node ids it returns node ids in addition to requested properties:
filter(search_matches, filterspec, sort=[], group=[], properties=[])
would return a list of items, where an item is either a nodeid, if
'properties' is empty, or a tuple containing nodeid, as well as all
requested properties of that node, otherwise.
Comments ? |
|
Date |
User |
Action |
Args |
2009-02-21 02:00:01 | stefan | set | messageid: <1235181601.07.0.75362654878.issue2550514@psf.upfronthosting.co.za> |
2009-02-21 02:00:01 | stefan | set | recipients:
+ stefan, richard |
2009-02-21 02:00:00 | stefan | link | issue2550514 messages |
2009-02-21 02:00:00 | stefan | create | |
|