title: How do I filter a dict to match the attributes of my ndb.Model subclass
body: <p>I have some simple models:</p>
  
  <pre><code>class MyModel1(ndb.Model):
      attribute1 = ndb.StringProperty()
      attribute2 = ndb.StringProperty()
  
  class MyModel2(MyModel1):
      attribute3 = ndb.StringProperty()
      attribute4 = ndb.StringProperty()
  </code></pre>
  
  <p>And I have an api that provides a json dict to a RequestHandler:</p>
  
  <pre><code>class APIRequestHandler(webapp2.RequestHandler):
      def dispatch(self):
          if len(self.request.body) &gt; 0:
              self.request.jsondata = json.loads(self.request.body)
          super(APIRequestHandler, self).dispatch()
  </code></pre>
  
  <p>And I have some concrete subclasses that support PUT:</p>
  
  <pre><code>class MyModel1Handler(APIRequestHandler):
  
      def put(self, key):
          mymodel1 = get_model(key)
          mymodel1.populate(**self.request.jsondata)
          mymodel1.put()
  #write the response
  
  class MyModel2Handler(APIRequestHandler):
  
      def put(self, key):
          mymodel2 = get_model(key)
          mymodel2.populate(**self.request.jsondata)
          mymodel2.put()
  #write the response
  </code></pre>
  
  <p>However, I'd like to filter the dict self.request.jsondata when calling populate removing any keys that are not attributes on the objects. Is there a simple pythonic way of doing this?</p>