[google-appengine] Re: TypeError: has_key() takes exactly 1 argument (2 given)
Mostly Classes CamelCase, modules lowercase, functions, methods and lowercase - is pretty much the norm but not always ;-) T On May 21, 9:47 am, Neal nwalt...@sprynet.com wrote: Thank to all for explaining this mysterious message and showing me the correction. It now works great! Another post gave me the clue on how to get the count working. def get(self): query = TaskLog.gql(WHERE resultFlag 0); # get all rows LIMIT = 1000 TaskLogs = query.fetch(LIMIT,offset=0); if TaskLogs.count(TaskLog) 0: self.renderPage('templates/list.html', {TaskLogs: TaskLogs}) else: self.response.out.write( h3Error - no TaskLogs returned from query/h3 ) Do Python developers usually make classes upper case and objects lower case? Neal Walters --~--~-~--~~~---~--~~ 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: TypeError: has_key() takes exactly 1 argument (2 given)
HI If you are interested here is the python style guide http://www.python.org/dev/peps/pep-0008/ T On May 21, 9:47 am, Neal nwalt...@sprynet.com wrote: Thank to all for explaining this mysterious message and showing me the correction. It now works great! Another post gave me the clue on how to get the count working. def get(self): query = TaskLog.gql(WHERE resultFlag 0); # get all rows LIMIT = 1000 TaskLogs = query.fetch(LIMIT,offset=0); if TaskLogs.count(TaskLog) 0: self.renderPage('templates/list.html', {TaskLogs: TaskLogs}) else: self.response.out.write( h3Error - no TaskLogs returned from query/h3 ) Do Python developers usually make classes upper case and objects lower case? Neal Walters --~--~-~--~~~---~--~~ 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: TypeError: has_key() takes exactly 1 argument (2 given)
Hi Neal, djidjadji's response correctly demonstrates what the problem is: The second argument to template.render should be a dictionary, not an individual object. The error you're seeing is because Django is trying to treat your TaskLog object as a dictionary. Change: self.renderPage('templates/list.html', TaskLogs) to: self.renderPage('templates/list.html', {TaskLogs: TaskLogs}) The other problem is that the 'TaskLogs' object is not a list - it's a single TaskLog object (or None, if there were no entities that matched your query). This is because you're calling .get() on the GqlQuery object, which returns the first match. You should probably be calling .fetch(limit). -Nick Johnson On Wed, May 20, 2009 at 5:04 AM, Neal nwalt...@sprynet.com wrote: Tim, So you don't use templates at all? Or some other package? I loved what I saw of Django, but then tried to build a vanilla app on GAE. But all the books I had, when talking about templates, used the Django template parser. Thanks, Neal On May 19, 8:00 pm, Tim Hoffman zutes...@gmail.com wrote: HINeal I don't know anything about django - (I don't use it on gae) all I am doing is pointing out what the error means This probably means you are passing the wrong argument to something in one of your templates. T On May 20, 3:30 am,Nealnwalt...@sprynet.com wrote: So basically, are you saying I have to change the Django code to get this work? If that's the case, surely everyone would be having the exact same problem??? How do I find out if I'm up to date or not? I just installed GAE about a month ago. I'm using the django template lib that comes with GAE. Neal- Hide quoted text - - Show quoted text - --~--~-~--~~~---~--~~ 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: TypeError: has_key() takes exactly 1 argument (2 given)
Hi Neal I do use templates but zpt based ones, I am not using any bits of django there are quite a few other python lightweight frameworks running on gae now. For alternatives have a look at things like pylons or repoze, however you will possibly be a bot more on your own as django is a bit of a default for gae seeing google is shipping it. T On May 20, 12:04 pm, Neal nwalt...@sprynet.com wrote: Tim, So you don't use templates at all? Or some other package? I loved what I saw of Django, but then tried to build a vanilla app on GAE. But all the books I had, when talking about templates, used the Django template parser. Thanks, Neal On May 19, 8:00 pm, Tim Hoffman zutes...@gmail.com wrote: HINeal I don't know anything about django - (I don't use it on gae) all I am doing is pointing out what the error means This probably means you are passing the wrong argument to something in one of your templates. T On May 20, 3:30 am,Nealnwalt...@sprynet.com wrote: So basically, are you saying I have to change the Django code to get this work? If that's the case, surely everyone would be having the exact same problem??? How do I find out if I'm up to date or not? I just installed GAE about a month ago. I'm using the django template lib that comes with GAE. Neal- Hide quoted text - - Show quoted text - --~--~-~--~~~---~--~~ 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: TypeError: has_key() takes exactly 1 argument (2 given)
Thank to all for explaining this mysterious message and showing me the correction. It now works great! Another post gave me the clue on how to get the count working. def get(self): query = TaskLog.gql(WHERE resultFlag 0); # get all rows LIMIT = 1000 TaskLogs = query.fetch(LIMIT,offset=0); if TaskLogs.count(TaskLog) 0: self.renderPage('templates/list.html', {TaskLogs: TaskLogs}) else: self.response.out.write( h3Error - no TaskLogs returned from query/h3 ) Do Python developers usually make classes upper case and objects lower case? Neal Walters --~--~-~--~~~---~--~~ 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: TypeError: has_key() takes exactly 1 argument (2 given)
Here is the entire template: {%block body%} h2List TaskLogs/h2 !-- List of TaskLogs -- ul table border=1 tr thCustomerBRDomain/th thWorker Email/th thTaskCode/th thStartedTime/th thCompletedTime/th thResultFlag/th thIssue/th /tr {%for TaskLog in TaskLogs%} tr td{{TaskLog.customerDomain}}/td td{{TaskLog.workerEmail}}/td td{{TaskLog.taskCode}}/td td{{TaskLog.eventStartedDateTime}}/td td{{TaskLog.eventCompletedDateTime}}/td td{{TaskLog.resultFlag}}/td td{{TaskLog.issues}}/td /tr !-- a href={%url views.edit gift.key.id%}{{gift.name|escape}}/ a - created {{gift.created|date:Y/m/d H:i:s}} by {{gift.giver}} -- {%endfor%} /ul /table {%endblock%} --~--~-~--~~~---~--~~ 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: TypeError: has_key() takes exactly 1 argument (2 given)
Sorry, I think I posted the wrong template, this is the one causing the error: {%block body%} h2List TaskLogs/h2 !-- List of TaskLogs -- ul table border=1 tr thCustomerBRDomain/th thWorker Email/th thTaskCode/th thStartedTime/th thCompletedTime/th thResultFlag/th thIssue/th /tr {%for TaskLog in TaskLogs%} tr td{{TaskLog.customerDomain}}/td td{{TaskLog.workerEmail}}/td td{{TaskLog.taskCode}}/td td{{TaskLog.eventStartedDateTime}}/td td{{TaskLog.eventCompletedDateTime}}/td td{{TaskLog.resultFlag}}/td td{{TaskLog.issues}}/td /tr !-- a href={%url views.edit gift.key.id%}{{gift.name|escape}}/ a - created {{gift.created|date:Y/m/d H:i:s}} by {{gift.giver}} -- {%endfor%} /ul /table {%endblock%} --~--~-~--~~~---~--~~ 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: TypeError: has_key() takes exactly 1 argument (2 given)
Hi Here's my guess as to what is going on Somewhere in django has_key(key) is being called which is traditionally a method of a dictionary that can check if a key is in the dictionary. Modern python code should really use key in somedict However app engine datastore class instances have a has_key method which doesn't take an argument, that just tells you if a datastore key has been generated for the entity (unfortunate choice of names I think) So somewhere someone is checking if a key is in a datastore entity as if it where a dictionary which won't work Hope this helps Rgds Tim On May 19, 10:17 pm, Neal nwalt...@sprynet.com wrote: Sorry, I think I posted the wrong template, this is the one causing the error: {%block body%} h2List TaskLogs/h2 !-- List of TaskLogs -- ul table border=1 tr thCustomerBRDomain/th thWorker Email/th thTaskCode/th thStartedTime/th thCompletedTime/th thResultFlag/th thIssue/th /tr {%for TaskLog in TaskLogs%} tr td{{TaskLog.customerDomain}}/td td{{TaskLog.workerEmail}}/td td{{TaskLog.taskCode}}/td td{{TaskLog.eventStartedDateTime}}/td td{{TaskLog.eventCompletedDateTime}}/td td{{TaskLog.resultFlag}}/td td{{TaskLog.issues}}/td /tr !-- a href={%url views.edit gift.key.id%}{{gift.name|escape}}/ a - created {{gift.created|date:Y/m/d H:i:s}} by {{gift.giver}} -- {%endfor%} /ul /table {%endblock%} --~--~-~--~~~---~--~~ 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: TypeError: has_key() takes exactly 1 argument (2 given)
So basically, are you saying I have to change the Django code to get this work? If that's the case, surely everyone would be having the exact same problem??? How do I find out if I'm up to date or not? I just installed GAE about a month ago. I'm using the django template lib that comes with GAE. Neal --~--~-~--~~~---~--~~ 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: TypeError: has_key() takes exactly 1 argument (2 given)
def get(self): query = db.GqlQuery(Select * from TaskLog) TaskLogs= query.get(); self.renderPage('templates/list.html', TaskLogs) Template {%for TaskLog in TaskLogs%} -- There are two things wrong with this python code The second arg to renderPage must be a dictionary with key-value pairs self.renderPage('templates/list.html', {'TaskLogs':TaskLogs}) The template for loop needs an iterable in the var TaskLogs in the context (the dict arg of renderPage). query.get() does not return an iterable. self.renderPage('templates/list.html', {'TaskLogs':[TaskLogs]}) The original TaskLogs is by Django interpreted as a context and asked for a certain dictionary key ('forloop') with has_key(key). But it is a db.Model instance with a has_key(self,key) method. --~--~-~--~~~---~--~~ 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: TypeError: has_key() takes exactly 1 argument (2 given)
Tim, So you don't use templates at all? Or some other package? I loved what I saw of Django, but then tried to build a vanilla app on GAE. But all the books I had, when talking about templates, used the Django template parser. Thanks, Neal On May 19, 8:00 pm, Tim Hoffman zutes...@gmail.com wrote: HINeal I don't know anything about django - (I don't use it on gae) all I am doing is pointing out what the error means This probably means you are passing the wrong argument to something in one of your templates. T On May 20, 3:30 am,Nealnwalt...@sprynet.com wrote: So basically, are you saying I have to change the Django code to get this work? If that's the case, surely everyone would be having the exact same problem??? How do I find out if I'm up to date or not? I just installed GAE about a month ago. I'm using the django template lib that comes with GAE. Neal- Hide quoted text - - Show quoted text - --~--~-~--~~~---~--~~ 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: TypeError: has_key() takes exactly 1 argument (2 given)
Here's more info. I'm running on my machine using the SDK. Traceback (most recent call last): File C:\Program Files\Google\google_appengine\google\appengine\ext \webapp\__init__.py, line 498, in __call__ handler.get(*groups) File c:\Program Files\Google\google_appengine\demos \DevGAEPasswordGen\passwordgenerator.py, line 133, in get self.renderPage('templates/list.html', TaskLogs) File c:\Program Files\Google\google_appengine\demos \DevGAEPasswordGen\passwordgenerator.py, line 124, in renderPage self.response.out.write(template.render(path, values)) File C:\Program Files\Google\google_appengine\google\appengine\ext \webapp\template.py, line 81, in render return t.render(Context(template_dict)) File C:\Program Files\Google\google_appengine\google\appengine\ext \webapp\template.py, line 121, in wrap_render return orig_render(context) File C:\Program Files\Google\google_appengine\lib\django\django \template\__init__.py, line 168, in render return self.nodelist.render(context) File C:\Program Files\Google\google_appengine\lib\django\django \template\__init__.py, line 705, in render bits.append(self.render_node(node, context)) File C:\Program Files\Google\google_appengine\lib\django\django \template\__init__.py, line 718, in render_node return(node.render(context)) File C:\Program Files\Google\google_appengine\lib\django\django \template\loader_tags.py, line 23, in render result = self.nodelist.render(context) File C:\Program Files\Google\google_appengine\lib\django\django \template\__init__.py, line 705, in render bits.append(self.render_node(node, context)) File C:\Program Files\Google\google_appengine\lib\django\django \template\__init__.py, line 718, in render_node return(node.render(context)) File C:\Program Files\Google\google_appengine\lib\django\django \template\defaulttags.py, line 87, in render if context.has_key('forloop'): File C:\Program Files\Google\google_appengine\lib\django\django \template\context.py, line 48, in has_key if d.has_key(key): TypeError: has_key() takes exactly 1 argument (2 given) So apparently the vanilla template actually uses Django code... I found the code at line 48: def has_key(self, key): for d in self.dicts: if d.has_key(key): # -- line 48 here return True return False But I'm still at a loss how to correct... Thanks, Neal --~--~-~--~~~---~--~~ 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: TypeError: has_key() takes exactly 1 argument (2 given)
What is the content of the template? There is a for loop executed and there it goes wrong. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---