Hi
Is there any particular reason why the api_key and scriptid couldn't
be used to make a entity key ?
ie obj = WorkTracker(key_name = "%s:%s" % (api_key,scriptid))
Then you can retrieve it by key using Model.get_by_key_name(key_names,
parent=None)
e.g.
obj = WorkTracker.get_by_key_name( "%s:%s" % (api_key,scriptid))
This is just one way of doing it without a query. You data model may
preclude you from doing this, for instance
you want the WorkTracker to be a child (in the same transaction group
as some other entitities)
then you need to know the ancestor.
If that is the case and you don't know the ancestor to use in
get_by_key_name, then get the record with
obj = WorkTracker.all().filter('api_key = ',api_key).filter('script_id
= ',script_id).get()
assuming that combination of api_key and script_id is unique.
This will be slower than accessing the entity directly by its key.
Rgds
T
On Nov 15, 4:22 am, deostroll <[email protected]> wrote:
> If u r looking for a scenario...I have a table called WorkTracker
> define like this:
>
> class WorkTracker(db.Model):
> api_key = db.StringProperty()
> scriptid = db.StringProperty()
> status = db.StringProperty()
> trials = db.IntegerProperty()
>
> There is a scheduled task which does its work based on scriptid and
> api_key...the task processes only 1 scriptid at a time (1 scripid per
> request). I am supposed to update the status of that particular record
> based on how the scheduled task was executed. So how do I write the
> update inside the scheduled job? Don't understand how 2 use db.get()
> in this context...there is no key_name...
>
> --deostroll
>
> On Nov 14, 11:04 pm, deostroll <[email protected]> wrote:
>
> > Don't understand the db.get(some_key) part...why is it possible to do
> > such a call in the first place...? I mean wht is so special in the db
> > model we've defined which allows us to do a db.get()...?
>
> > --deostroll
--
You received this message because you are subscribed to the Google Groups
"Google App Engine" group.
To post to this group, send email to [email protected].
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=.