title: How can I create functions that work for different Model classes in GAE?
body: <p>I have multiple classes for which I have special functions that query ndb in a shorter way, like in this example:</p>
  
  <pre class="lang-py prettyprint-override"><code>class SomeModel(ndb.Model):
      xcode = ndb.StringProperty('c')
      descr = ndb.StringProperty('d')
      client = ndb.KeyProperty('cl')
      order = ndb.IntegerProperty('o')
      mod = ndb.DateTimeProperty(auto_now=True)
  
      @classmethod
      def q_base(cls, ancestor):
          return cls.query(ancestor=ancestor).order(cls.codigo)
  </code></pre>
  
  <p>The function q_base saves some space and makes the code in the handlers look clearer. But since quite a few models need this exact function, I have to repeat it multiple times, which is a problem.</p>
  
  <p>How can I solve it? Can I just make a BaseClass(ndb.Model), add the functions there and make every other model inherit from it? Or do I have to use PolyModel for that? How would that look? Also, I would appreciate any insight as to what would happen to any existint entities.</p>