If you put your own __init__ in your model classes, you can count how
many times instances are created.  You can then watch the count to
figure out where/when those model classes are created.  Since
successful datastore queries create instances of model classes....

# watch A._counter
class A(db.Model):
    _counter = 0
    def __init__(self, *args, **kwds):
        A._counter += 1
        super(A, self).__init__(*args, **kwds)

On Oct 11, 10:55 am, Jeff Nichols <[EMAIL PROTECTED]> wrote:
> Answering my own question here...
>
> father = Father.all().filter("name =", "John").get()
> father.name = "Doe"
> sons = father.son_set.fetch(1000)
> print sons[0].father.name  #prints 'John'
>
> Maybe I'm just used to more 'traditional' ORM systems, but that seems
> to me unintuitive.  Not too mention inefficient.  Since Google is so
> concerned with performance, you'd think they would have built-in some
> sort of level 1 cache for entities.  Oh well...
>
> And I'd still like to be able to have a datastore access log.
>
> Jeff
>
> On Oct 11, 4:29 pm, Jeff Nichols <[EMAIL PROTECTED]> wrote:
>
>
>
> > Hello,
>
> > Say I have a one-to-many relationship between 'Father' and 'Son'
> > modeled with a reference property on the Son entity.  After fetching
> > all sons of a father, are the father references of those sons
> > prepopulated, or will they also be fetched?  Illustrated in code...
>
> > class Father(db.Model):
> >   name = db.StringProperty()
>
> > class Son(db.Model):
> >   father = db.ReferenceProperty(Father)
>
> > father = Father.get_by_key_name(some_key)  # DataStore access
> > sons = father.son_set.fetch(1000)  # DataStore access
> > for son in sons:
> >   logging.info(son.father.name)  # DataStore access???
>
> > On a side note, I could figure this out myself if there were some way
> > to log datastore access.  Have I looked over some way to enabled this
> > sort of logging?
>
> > Thanks,
> > Jeff- Hide quoted text -
>
> - Show quoted text -
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To post to this group, send email to google-appengine@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to