Quote:
Originally Posted by capink
I wrote this a long time ago, so I don't remember the details. The slice was intentional to create a new list (a substitute for copy.copy()), because I needed to preserve the original one (I don't remember the details now).
Edit: Looking at the code now, I guess the slicing might have been an attempt to improve performance of the template function, by not having to iterate over items that have been already processed.
|
That makes sense, given the .remove(). You certainly don't want to change the list maintained by the db layer! Have you checked that you can safely remove an item in the list in the current for iterator? I don't know ...
Quote:
The mi._proxy_metadata.user_categories was the way I saw it done in one of the builtin template functions. But since you recommend mi.user_categories(), I will be using that instead.
|
Yes, I see now that I did that. I don't remember why. Regardless, it isn't needed. If user_categories is referenced (it is an attribute, not a function) then the "right thing" will happen no matter if the base class is a proxy_metadata instance or a 'real' mi instance. In most cases it will be a proxy_metadata instance. I will (eventually) change the reference in formatter_functions.2,315: def user_categories_for_books()