How do I customise subclassing behaviour or require subclassing in a particular way?
<p>Let's say I'm building a class called <code>ModelController</code>. I want this class to have a bunch of methods that can wrap a separate <code>Model</code> class, which is my database abstraction.</p>

<p>I want to be able to define a class method on <code>ModelController</code> like so:</p>

<pre><code>ModelController():
  @classmethod
  def list(cls):
    cls.model.list()
  @classmethod
  def byName(cls, name):
    return cls.model(name)
</code></pre>

<p>And have Model class like this:</p>

<pre><code>ArticleModel(Model):
    pass
</code></pre>

<p>And then do something like this:</p>

<pre><code>ArticleModelController(ModelController):
  # ??? maybe:
  # model = ArticleModel
</code></pre>

<p>I suppose I could just subclass my Model classes for a controller and then have some kind of mixin pattern, but the reason I want the model to be a class attribute of the controller is that I really don't want to risk accidentally exposing some of its methods over HTTP when I mount this class in a cherrypy method dispatcher or something like that.</p>

<p>Maybe I'm doing something fundamentally un-pythonic or committing some kind of fallacy. Am I trying to do 'magic'?</p>

<p>edit: I just remembered my old days of Django and its ModelForms. They work like this:</p>

<pre><code>class ArticleForm(ModelForm):
    class Meta:
        model = Article
</code></pre>

<p>Perhaps this is what I should be looking at. Is it possible to validate that this 'model' attribute is defined and throw an error if something is subclassed without it being undefined?</p>
