@classmethod with Abstract Base Class
Question: I have an Abstract Base Class and subclasses defined as follows (Python 2.7):

    
    
    import abc
    import MyDatabaseModule
    
    class _DbObject(object):
        __metaclass__ = abc.ABCMeta
    
        def _GetObjectType(self):
            raise NotImplementedError, "Please override in the derived class"
    
        ObjectType = abc.abstractproperty(_GetObjectType, None)
    
    class Entry(_DbObject):
        _objectTypeID = 'ENTRY'
    
        def _GetObjectType(self):
            return MyDatabaseModule.DoesSomethingWith(self._objectTypeID)
    
        ObjectType = property(_GetObjectType, None)
    

This works fine, meaning that the base class `_DbObject` cannot be
instantiated because it has only an abstract version of the property getter
method.

    
    
    try:
        dbObject = _DbObject()
        print "dbObject.ObjectType: " + dbObject.ObjectType
    except Exception, err:
        print 'ERROR:', str(err) 
    

Now I can do:

    
    
    entry = Entry()
    print entry.ObjectType
    

to get access to the `ObjectType` property. However, what I would like to be
able to do is just:

    
    
    print Entry.ObjectType
    

However, wherever I try to insert `@classmethod`, I get the error `classmethod
object is not callabale`.


Answer: The problem is not your `ABC` but the simple fact, that there is no such thing
as a `classproperty` in python, you have to create it on your own. Actually
there is a good [question + answer on
SO](http://stackoverflow.com/questions/128573/using-property-on-classmethods)
about that. It actually should be no problem using it with your ABC aswell.

