title: GAE converting dictionary to NDB datastore entity
body: <p>I would like to ask some guidelines on a small task that I am trying to solve.
  I am experimenting with a small app that uses JSON data to save entities.</p>
  
  <p>I know that you can easily convert a dict to an entity by just creating the model but, I am trying to build a more generic approach that would convert any dict to an entity.</p>
  
  <p>My steps are:</p>
  
  <ol>
  <li>Get the dict.</li>
  <li>Validate that the dict keys correspond to an entitys model definitions by reading the class.<strong>dict</strong> of the model.</li>
  <li>Try to unpack the validated properties in the model class contructor (create the model instance) </li>
  <li>return it. </li>
  </ol>
  
  <p>So far I am ok but lack of my python knowledge, is either constraining me, or confusing me.
  Maybe I am as well forgetting or unaware of  more simple way to do it.</p>
  
  <p>So here is it: </p>
  
  <pre><code>@classmethod
  def entity_from_dict(cls, parent_key, dict):
      valid_properties = {}
      logging.info(cls.__dict__)
      for property,value in dict.iteritems():
          if property in cls.__dict__: # should  not iterate over functions, classmethods, and @property
              logging.info(cls.__dict__[property]) # this outputs eg: StringProperty('title', required=True)
              logging.info(type(cls.__dict__[property])) #this is more interesting &lt;class 'google.appengine.ext.ndb.model.StringProperty'&gt;
              valid_properties.update({property: value})
      # Update the id from the dict
      if 'id' in dict: # if not creating a new entity
              valid_properties['id'] = dict['id']
      # Add the parent
      valid_properties['parent'] = parent_key
      #logging.info(valid_properties)
      try:
          entity = cls(**valid_properties)
      except Exception as e:
          logging.exception('Could not create entity \n' + repr(e))
          return False
      return entity
  </code></pre>
  
  <p>My problem is that I want only to validate ndb. Properties and not @classmethods, @property as well because this causes a conflict.</p>
  
  <p>I am also using expando classes, so any property in the dict that is extra gets stored.</p>
  
  <p>How can I check against these specific types? </p>