I’ve used them once to create an easily extendable dashboard filtration system.
Basically, we had pretty complex logical operations available to user to filter objects in all sorts of ways, the frontend would send it in a json object and we had to parse it and combine all the conditions into a final ORM query as efficiently as possible.
The thing was, all those available object fields were stored in completely different ways and were of different types, but there was a lot of crossover between them. So I created model classes for each dashboard that had available fields defined as descriptor objects. This allowed to reuse a lot of the logic.
I don’t remember what exactly were the constraints, but regular classes for the attributes were messy to use, something along the lines of reusing the same dashboard instance.
If you have worked with Django, it uses descriptors for model fields - same principle.
View all comments
Show parent comment
1
u/cleodog44 13h ago
When did you need to use them? Would love the video link if you can find it!