title: GAE (Python): How to get a key from StructuredProperty?
body: <p>I have these classes:</p>
  
  <pre><code>class X(ndb.Model):
    field1 = ndb.StringProperty(indexed=True)
  
  class Y(ndb.Model):
    ref = ndb.StructuredProperty(X)
    field2 = ndb.StringProperty(indexed=False)
  
  class Z(ndb.Model):
    refs = ndb.StructuredProperty(Y, repeated=True)
  </code></pre>
  
  <p>If I have a object of type <code>Z</code> called <code>z</code>then I can get a key for it by calling <code>z.key</code>. Assuming that I have some objects added to <code>z</code> field refs, how can I traverse then to get the keys for objects of type <code>X</code> and <code>Y</code>?</p>
  
  <p>I have tried <code>z.refs[0].key</code>and <code>z.refs[0].ref.key</code>, but they return None. I can refer to <code>z.refs[0].field2</code> and <code>z.refs[0].ref.field1</code> just fine.</p>
  
  <p>I have tried to switch StructuredProperty to LocalStructuredProperty, but that didn't change anything.</p>