[google-appengine] Re: Query() vs. GqlQuery() different results for the same queries (Python)

2009-04-23 Thread djidjadji

Wrong:  filter("checkpoint_id=", bus.checkpoint_id)
Right:filter("checkpoint_id =", bus.checkpoint_id)


2009/4/22 风笑雪 :
> You mean this?
> Wrong:  filter("checkpoint_id=", bus.checkpoint_id)
> Right:filter("checkpoint_id= ", bus.checkpoint_id)
>
> 2009/4/22 Dmitry Kachaev 
>>
>> I got it, thanks all!
>>
>> It was a lack of space between property name and operator in filter()
>> method. It led to empty result (but not an exception???)
>>
>> -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
-~--~~~~--~~--~--~---



[google-appengine] Re: Query() vs. GqlQuery() different results for the same queries (Python)

2009-04-22 Thread Dmitry Kachaev

Exactly.

Looking at exceptions reference I would expect BadQueryError or
BadArgumentError to be raised in wrong call.

Thanks again for helping me on this.

-Dmitry

On Apr 22, 7:26 am, 风笑雪  wrote:
> You mean this?
> Wrong:  filter("checkpoint_id=", bus.checkpoint_id)
> Right:filter("checkpoint_id= ", bus.checkpoint_id)
>
> 2009/4/22 Dmitry Kachaev 
>
>
>
> > I got it, thanks all!
>
> > It was a lack of space between property name and operator in filter()
> > method. It led to empty result (but not an exception???)
>
> > -Dmitry
>
> > On Apr 21, 11:52 am, Mark Wolgemuth  wrote:
> > > 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  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, 风笑雪  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 
>
> > > > > > 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
-~--~~~~--~~--~--~---



[google-appengine] Re: Query() vs. GqlQuery() different results for the same queries (Python)

2009-04-22 Thread 风笑雪
You mean this?
Wrong:  filter("checkpoint_id=", bus.checkpoint_id)
Right:filter("checkpoint_id= ", bus.checkpoint_id)

2009/4/22 Dmitry Kachaev 

>
> I got it, thanks all!
>
> It was a lack of space between property name and operator in filter()
> method. It led to empty result (but not an exception???)
>
> -Dmitry
>
> On Apr 21, 11:52 am, Mark Wolgemuth  wrote:
> > 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  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, 风笑雪  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 
> >
> > > > > 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
-~--~~~~--~~--~--~---



[google-appengine] Re: Query() vs. GqlQuery() different results for the same queries (Python)

2009-04-21 Thread Dmitry Kachaev

I got it, thanks all!

It was a lack of space between property name and operator in filter()
method. It led to empty result (but not an exception???)

-Dmitry

On Apr 21, 11:52 am, Mark Wolgemuth  wrote:
> 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  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, 风笑雪  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 
>
> > > > 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
-~--~~~~--~~--~--~---



[google-appengine] Re: Query() vs. GqlQuery() different results for the same queries (Python)

2009-04-21 Thread Mark Wolgemuth

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  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, 风笑雪  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 
>
> > > 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
-~--~~~~--~~--~--~---



[google-appengine] Re: Query() vs. GqlQuery() different results for the same queries (Python)

2009-04-21 Thread Dmitry Kachaev

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, 风笑雪  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 
>
>
>
> > 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
-~--~~~~--~~--~--~---



[google-appengine] Re: Query() vs. GqlQuery() different results for the same queries (Python)

2009-04-21 Thread Nick Johnson (Google)

Apologies, my previous message was in error. Without more of your
source, it's hard to tell what's going wrong, though.

Also, this pattern:

db.GqlQuery("SELECT * FROM Checkpoint WHERE checkpoint_id = %s" %
(bus.checkpoint_id))

is extremely dangerous. You should never, ever do string substitution
in a GQL (or SQL!) query. GQL directly supports parameterized queries,
so instead you can equivalently (and far more safely) do:

db.GqlQuery("SELECT * FROM Checkpoint WHERE checkpoint_id = :1",
bus.checkpoint_id)


-Nick Johnson

On Apr 21, 1:07 pm, "Nick Johnson (Google)" 
wrote:
> Hi Dmitry,
>
> The issue here isn't with the query, but with your code that's calling
> it. Python is throwing an exception because your variable 'bus' that
> you're trying to fetch checkpoint_id on is set to None, not because
> the result of the query is None. The query code never gets run.
>
> -Nick Johnson
>
> On Apr 21, 12:56 pm, Dmitry Kachaev  wrote:
>
> > 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
-~--~~~~--~~--~--~---



[google-appengine] Re: Query() vs. GqlQuery() different results for the same queries (Python)

2009-04-21 Thread Nick Johnson (Google)

Hi Dmitry,

The issue here isn't with the query, but with your code that's calling
it. Python is throwing an exception because your variable 'bus' that
you're trying to fetch checkpoint_id on is set to None, not because
the result of the query is None. The query code never gets run.

-Nick Johnson


On Apr 21, 12:56 pm, Dmitry Kachaev  wrote:
> 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
-~--~~~~--~~--~--~---



[google-appengine] Re: Query() vs. GqlQuery() different results for the same queries (Python)

2009-04-21 Thread 风笑雪
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 

>
> 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
-~--~~~~--~~--~--~---