I think your second one may be "working" because using the string
substitution is causing an unexpected value to appear in the query
that still is accepted by the engine. You should generate a log entry
before the query to see what passing the id to %s is actually giving
you.

On Apr 21, 8:10 am, Dmitry Kachaev <dmitry.kach...@gmail.com> wrote:
> Yes, Checkpoint class is defined in models package.
>
> bus.checkpoint_id has value (in both cases, I can see it in debug
> messages)
>
> -Dmitry
>
> On Apr 21, 8:04 am, 风笑雪 <kea...@gmail.com> wrote:
>
> > Why you use models.Checkpoint?
> > Is the Checkpoint class defines in models package/module?
>
> > If not, use this:
> > point_old = Checkpoint.all().filter("checkpoint_id=",
> > bus.checkpoint_id).get()
>
> > And for the "'NoneType' object has no attribute 'checkpoint_id'", you should
> > check bus.checkpoint_id to ensure it's not None.
>
> > 2009/4/21 Dmitry Kachaev <dmitry.kach...@gmail.com>
>
> > > I use following construction to lookup records from datastore:
>
> > >            point_old=models.Checkpoint.all().filter("checkpoint_id
> > > =", bus.checkpoint_id).get()
>
> > > It works fine in most scenarios, but sometime I'm getting error like
> > > this:
>
> > > 'NoneType' object has no attribute 'checkpoint_id'
> > > Traceback (most recent call last):
> > >  File "/base/python_lib/versions/1/google/appengine/ext/webapp/
> > > __init__.py", line 501, in __call__
> > >    handler.get(*groups)
> > >  File "/base/data/home/apps/xxx/1.332943763447248076/tasks/
> > > busupdate.py", line 22, in get
> > >    self.update(bus)
> > >  File "/base/data/home/apps/xxx/1.332943763447248076/tasks/
> > > busupdate.py", line 45, in update
> > >    self.check_points(bus)
> > >  File "/base/data/home/apps/xxx/1.332943763447248076/tasks/
> > > busupdate.py", line 86, in check_points
> > >    logging.debug("found old checkpoint: %s" %
> > > (point_old.checkpoint_id))
> > > AttributeError: 'NoneType' object has no attribute 'checkpoint_id'
>
> > > Basically, get() returns None, but record I looked up is definitely in
> > > datastore.
>
> > > I figured out and replaced this look up call with equivalent GQL call:
>
> > >            point_old = db.GqlQuery("SELECT * FROM Checkpoint WHERE
> > > checkpoint_id = %s" % (bus.checkpoint_id)).get()
> > >            #point_old=models.Checkpoint.all().filter("checkpoint_id
> > > =", bus.checkpoint_id).get()
>
> > > What is wrong? Those constructs should behave the same way, but they
> > > don't. Commented one is not returning a record, when GQL is returning
> > > single record, just fine.
>
> > > Thanks,
> > > Dmitry
--~--~---------~--~----~------------~-------~--~----~
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 
google-appengine+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to