Message from discussion
ReferenceProperty - id access without fetching the entity
MIME-Version: 1.0
Received: by 10.100.151.5 with SMTP id y5mr11671and.25.1222984921801; Thu, 02
Oct 2008 15:02:01 -0700 (PDT)
Date: Thu, 2 Oct 2008 15:02:01 -0700 (PDT)
In-Reply-To: <04710183-cf45-49e2-87d0-f2fe112383f3@m3g2000hsc.googlegroups.com>
X-IP: 172.31.135.232
References: <04710183-cf45-49e2-87d0-f2fe112383f3@m3g2000hsc.googlegroups.com>
User-Agent: G2/1.0
X-HTTP-UserAgent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US;
rv:1.9.0.3; Google-TR-3) Gecko/2008092414 Firefox/3.0.3,gzip(gfe),gzip(gfe)
Message-ID: <975c4bd0-30db-4876-8825-344ff155257f@m3g2000hsc.googlegroups.com>
Subject: Re: ReferenceProperty - id access without fetching the entity
From: Rafe <slobberch...@gmail.com>
To: Google App Engine <google-appengine@googlegroups.com>
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Mazia is correct, there is no guarantee that this will work. In
fact, it is very likely it will not work in the future. We may in the
future implement lazy loading so that you can access the key directly
without loading the entity (a.C.key()) however, for now, this is
guaranteed to work:
A.C.get_value_for_datastore(a).key()
On Sep 29, 6:23=A0pm, Andy Freeman <ana...@earthlink.net> wrote:
> Is there an approved way to copy a ReferenceProperty from one entity
> to another without fetching the referred to entity from the datastore?
>
> In other words,
>
> class C(db.Model):
> =A0 =A0 ...
>
> class A(db.Model):
> =A0 =A0 C =3D db.ReferenceProperty(reference_class=3DC)
>
> class B(db.Model):
> =A0 =A0 C =3D db.ReferenceProperty(reference_class=3DC)
>
> a =3D {some query}
> b =3D B()
> # I would like to do the next assignment without retrieving the
> relevant entity
> # from the data store.
> b.C =3D a.C
>
> Yes, I know that a._C.id() can be used to read the id, but that