patchew-project / patchew

A patch email tracking and testing system
MIT License
73 stars 24 forks source link

Use class-based views #34

Open bonzini opened 6 years ago

bonzini commented 6 years ago

Class-based views make it easier, for example, to memoize prepare_message results.

famz commented 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?

bonzini commented 6 years ago

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).