Open bonzini opened 6 years ago
OK, so currently we use method based views. I can make some vague sense out of class based views, but not sure I understand the "for example" part you mean?
Right now, calling prepare_message
more than once for the same message does the same query twice. By using CBVs, you can add a dict to the class that associates a message id to an object that has gone through prepare_message
already. This way, when the same message is passed twice through prepare_message
, you don't need a second query.
(In theory you shouldn't need to call it twice on one message, but it happens with the plugins farI could understand).
Class-based views make it easier, for example, to memoize
prepare_message
results.