How to create instances of a class from a static method?
<p>Here is my problem. I have created a pretty heavy readonly class making many database calls with a static "factory" method. The goal of this method is to avoid killing the database by looking in a pool of already-created objects if an identical instance of the same object (same type, same init parameters) already exists.</p>

<p>If something was found, the method will just return it. No problem. But if not, how may I create an instance of the object, in a way that works with inheritance?</p>

<pre><code>&gt;&gt;&gt; class A(Object):
&gt;&gt;&gt;     @classmethod
&gt;&gt;&gt;     def get_cached_obj(self, some_identifier):
&gt;&gt;&gt;         # Should do something like `return A(idenfier)`, but in a way that works

&gt;&gt;&gt; class B(A):
&gt;&gt;&gt;     pass

&gt;&gt;&gt; A.get_cached_obj('foo') # Should do the same as A('foo')
&gt;&gt;&gt; A().get_cached_obj('foo') # Should do the same as A('foo')
&gt;&gt;&gt; B.get_cached_obj('bar') # Should do the same as B('bar')
&gt;&gt;&gt; B().get_cached_obj('bar') # Should do the same as B('bar')
</code></pre>

<p>Thanks.</p>
