suddenly, a new error in Cheetah in production GAE, doesn't occur in SDK

3 views
Skip to first unread message

Ben Adida

unread,
Nov 14, 2008, 12:40:55 PM11/14/08
to Google App Engine

Suddenly, I'm getting the following errors on just about every page:

if hasattr(obj, 'has_key') and obj.has_key(key):
TypeError: has_key() takes exactly 1 argument (2 given)

This is within the Cheetah templating library, _valueForName function.
I haven't modified the Cheetah code, nor have I modified my
application at GAE in the last few days.

And I can't reproduce this error in my local SDK installation.

Did GAE just change some internal libraries? I don't even understand
why has_key() would ever take only one argument...

Marzia Niccolai

unread,
Nov 14, 2008, 12:49:07 PM11/14/08
to google-a...@googlegroups.com
Hi Ben,

Can you provide a more complete example of the code that causes this issue? As well as the complete stack trace.

Thanks,
Marzia

Ben Adida

unread,
Nov 14, 2008, 2:51:27 PM11/14/08
to Google App Engine
Marzia,

It's a little difficult to cut down the example to size, because *all*
of my pages that render content from the store are giving errors.
Here's one URL where the issue comes up:

http://dev.heliosvoting.org/elections/ahBkZXYtaGVsaW9zdm90aW5ncg8LEghFbGVjdGlvbhiRAww/view

and that will give you the complete stack trace.

Let me know if that helps, and thanks.

-Ben

Marzia Niccolai

unread,
Nov 14, 2008, 6:01:37 PM11/14/08
to google-a...@googlegroups.com
Hi Ben,

It's difficult to know what this stack trace means with out an idea of what kind of obj the has_key method belongs to.  Would it be possible to at least provide the template that is being rendered? And a description of what one expects to be rendered?

-Marzia

Ben Adida

unread,
Nov 14, 2008, 6:19:18 PM11/14/08
to Google App Engine
Hi Marzia,

Thanks again for your help.

I want to stress that this started happening with no change in code on
my end. And it works just fine in the SDK. Was there a library change
of any kind in GAE over the last few days?

The source code for my app is entirely public. Here's the template in
particular:

http://github.com/benadida/helios/tree/master/templates/election/one.tmpl

and the controller

http://github.com/benadida/helios/tree/master/controllers/election.py

line 395.

Thanks again,

-Ben

On Nov 14, 3:01 pm, Marzia Niccolai <ma...@google.com> wrote:
> Hi Ben,
>
> It's difficult to know what this stack trace means with out an idea of what
> kind of obj the has_key method belongs to.  Would it be possible to at least
> provide the template that is being rendered? And a description of what one
> expects to be rendered?
>
> -Marzia
>
> On Fri, Nov 14, 2008 at 11:51 AM, Ben Adida <b...@adida.net> wrote:
>
> > Marzia,
>
> > It's a little difficult to cut down the example to size, because *all*
> > of my pages that render content from the store are giving errors.
> > Here's one URL where the issue comes up:
>
> >http://dev.heliosvoting.org/elections/ahBkZXYtaGVsaW9zdm90aW5ncg8LEgh...

Marzia Niccolai

unread,
Nov 15, 2008, 4:07:14 PM11/15/08
to google-a...@googlegroups.com
Hi Ben,

The recent maintenance included some changes to db.py, including adding a has_key function, which seems to be causing the error with template rendering.

The new SDK has not yet been released, but the easiest/quickest fix would be to take the google.appengine.ext.db __init__.py file from 1.1.5, rename it, and included it with your application. 

Just change the imports, replacing from google.appengine.ext import db with from Db import db (assuming you changed the name of __init__.py to Db.py, for instance).

Hope this helps, sorry for the confusion!

-Marzia

Ben Adida

unread,
Nov 16, 2008, 1:20:05 PM11/16/08
to Google App Engine
Hi Marzia,

Thanks for the explanation!

I'm a little bit surprised that the production API would change on its
own like this. This makes a production application incredibly unstable
if the underlying GAE API can change without warning. Is there any
plan to allow an application to freeze the API on which it relies so
that this kind of instability doesn't occur? Or is this simply because
GAE is in beta and when (hopefully soon) it goes "production" then
this won't happen?

-Ben

On Nov 15, 1:07 pm, Marzia Niccolai <ma...@google.com> wrote:
> Hi Ben,
>
> The recent maintenance included some changes to db.py, including adding a
> has_key function, which seems to be causing the error with template
> rendering.
>
> The new SDK has not yet been released, but the easiest/quickest fix would be
> to take the google.appengine.ext.db __init__.py file from 1.1.5, rename it,
> and included it with your application.
>
> Just change the imports, replacing from google.appengine.ext import db with
> from Db import db (assuming you changed the name of __init__.py to Db.py,
> for instance).
>
> Hope this helps, sorry for the confusion!
>
> -Marzia
>
> On Fri, Nov 14, 2008 at 3:19 PM, Ben Adida <b...@adida.net> wrote:
>
> > Hi Marzia,
>
> > Thanks again for your help.
>
> > I want to stress that this started happening with no change in code on
> > my end. And it works just fine in the SDK. Was there a library change
> > of any kind in GAE over the last few days?
>
> > The source code for my app is entirely public. Here's the template in
> > particular:
>
> >http://github.com/benadida/helios/tree/master/templates/election/one....

Marzia Niccolai

unread,
Nov 17, 2008, 7:10:53 PM11/17/08
to google-a...@googlegroups.com
Hi Ben,

It's certainly not our desire to introduce any changes in the App Engine library that would break our users app, but from time to time some parts of the apis and libraries will be modified to fix issues/enhance features.

When these fixes happen, it's always possible that this will break a certain subset of applications who are implicitly or incorrectly assuming certain features of the API.  Of course, we'd like to avoid this when possible, but sometimes it's difficult to anticipate how some of these changes can affect certain applications.

We are certainly working on finding the right balance, and hope that as we continue development with App Engine these kind of things will happen less often.

-Marzia

James Ashley

unread,
Nov 18, 2008, 1:47:50 PM11/18/08
to Google App Engine
Marzia,

I don't want to seem disagreeable, unappreciative, or anything like
that. But I really have to agree with Ben on this one.

It seems to me that this change introduces a bug. I've been using
python for 8 years now, and I can't think of any reason for a has_key
method to take only one argument (its parameter list is always (self,
key_name)). That's a fairly core part of the language. If you're
going to introduce a new method that does something vaguely similar,
but changes things significantly like this, IMHO, you should really
give it a different name.

Then again, you do have Guido on hand, and his whim certainly trumps
anything anyone else might say. Maybe he's already vetted this
decision, and I need to just shut up and mind my own business.

Thank you for the help and support you're providing,
James

On Nov 17, 6:10 pm, Marzia Niccolai <ma...@google.com> wrote:
> Hi Ben,
>
Reply all
Reply to author
Forward
0 new messages