Opened 11 years ago
Closed 11 years ago
#21011 closed Uncategorized (invalid)
It should be possible for model classes to have abstract methods
Reported by: | steven_ganz | Owned by: | nobody |
---|---|---|---|
Component: | Uncategorized | Version: | 1.5 |
Severity: | Normal | Keywords: | ABCMeta |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
This is 'abstract' in terms of ABCMeta and has nothing to do with setting 'abstract = True' (i.e., use of abstract methods should be possible regardless of the setting of 'abstract')
Any attempt to set
__metaclass__ = ABCMeta
gives:
TypeError: Error when calling the metaclass bases metaclass conflict: the metaclass of a derived class must be a (non-strict) subclass of the metaclasses of all its bases
Unfortunately, the solution is not as simple as setting this attribute for Model and ModelBase.
Note:
See TracTickets
for help on using tickets.
In this scenario
__metaclass__
must be a subclass of bothModel
's metaclass (namelyModelBase
) andABCMeta
.I would advise against using metaclasses if the above isn't obvious to you.