Comment 6 for bug 231106

Revision history for this message
Martijn Faassen (faassen) wrote :

Actually Philipp pointed me to the double sort. I don't think that's needed, as sort_components will sort any sort of component, no matter whether grok.order() is used.

I therefore suspect that we can massively simplify the code to:

def sort(self, viewlets):
   return util.sort_components((viewlet for name, viewlet in viewlets))

We have very extensive tests for this sorting in Grok already, and class name is definitely one of the things that is used already.

I don't understand where all the complexity of indexed_viewlets comes from. What's the motivation?

I see that the standard viewlets code sorts by viewlet name as the viewlet is registered in the CA, not class name. Anyway, if we want this to factor into the sorting behavior as well, we could modify sort_components. First I'd like to hear a good reason that this is actually useful.

With grok order, if you want to make order explicit, use grok.order(some_number). If you don't want to make it explicit but just by definition order of viewlets, use grok.order() (which will sort after explicit order). If you don't care, leave it out entirely, it'll be by class name (which will sort after any actual use of grok.order()). It'll also use module names to have consistent sorting of viewlets defined in different modules.