[Python-Dev] Class decorators (original) (raw)
Greg Ewing greg.ewing at canterbury.ac.nz
Thu Mar 30 04:42:22 CEST 2006
- Previous message: [Python-Dev] Class decorators
- Next message: [Python-Dev] Class decorators
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Jack Diederich wrote:
Using metaclasses also required gross hacks like checking for a 'DONOTREGISTER' member for subclasses that wanted to inherit from a class that had a Register metaclass but didn't want to be registered.
I've just done something like this myself in the last few days, and my solution was to have the registration metaclass look for an attribute in the class's dict, instead of using attribute access on the class, to decide whether to register it.
That way the registerability doesn't get inherited, and I get to choose individually for each class.
This of course may not be such a good idea if you want registerability to usually be inherited, but not always. In that case, you need some way of saying when you don't want it, in which case a do-not-register attribute doesn't seem so bad. How else would you provide this information?
Still want class decorators, though. :-)
BTW, the system I'm working on is a response to some hair-tearing problems I was experiencing trying to pickle some of my data, and also to address some disadvantages I see in using pickle for long-term data storage. I'll write something up about it if it works out...
-- Greg Ewing, Computer Science Dept, +--------------------------------------+ University of Canterbury, | Carpe post meridiam! | Christchurch, New Zealand | (I'm not a morning person.) | greg.ewing at canterbury.ac.nz +--------------------------------------+
- Previous message: [Python-Dev] Class decorators
- Next message: [Python-Dev] Class decorators
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]