Hey everyone,
I am fairly new to python, and I was working on a google app engine project for a class, and this error came up. I wasn't sure why, because right above it I have the same object type right above it, and when I take the filter off the other, it works fine, I just can't do that or it screws everything up -
def LoginBar():
-
user = users.get_current_user()
-
greet = Greeting.all()
-
info = greet
-
greet.filter("username =", user)
-
info = Greeting.all()
-
url_account_linktext = "Account"
-
check = 0
-
if user:
-
for info in greet:
-
if info.username == user:
-
check = 1
-
break
-
if check == 0:
-
greeting = Greeting()
-
greeting.username = users.get_current_user()
-
greeting.email = user.email()
-
greeting.name = greeting.username.nickname()
-
greeting.put()
-
-
url = users.create_logout_url('/')
-
url_linktext = 'Logout'
-
else:
-
url = users.create_login_url('/')
-
url_linktext = 'Login'
-
template_values = {
-
'info': info,
-
'greetings': greet,
-
'url': url,
-
'url_linktext': url_linktext,
-
'url_account_linktext': url_account_linktext,
-
}
-
If I use the info variable in this code -
{% for greeting in info %}
-
<br /><b>{{ greeting.name }}</b><br />
-
{% endfor %}
-
it throws this exception, but if I put greet in there, whether it is filtered or not, it works. Any ideas why? I really wish I could use greet, but that doesn't work, sadly, because I use it else where for other stuff. Thanks in advance
Edit, here is the traceback -
Traceback (most recent call last):
-
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\ext\webapp\__init__.py", line 515, in __call__
-
handler.get(*groups)
-
File "C:\Users\William\Documents\workspace\242Homework2\src\homework\main.py", line 109, in get
-
self.response.out.write(template.render(path, values))
-
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\ext\webapp\template.py", line 143, in render
-
return t.render(Context(template_dict))
-
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\ext\webapp\template.py", line 183, in wrap_render
-
return orig_render(context)
-
File "C:\Program Files (x86)\Google\google_appengine\lib\django\django\template\__init__.py", line 168, in render
-
return self.nodelist.render(context)
-
File "C:\Program Files (x86)\Google\google_appengine\lib\django\django\template\__init__.py", line 705, in render
-
bits.append(self.render_node(node, context))
-
File "C:\Program Files (x86)\Google\google_appengine\lib\django\django\template\__init__.py", line 718, in render_node
-
return(node.render(context))
-
File "C:\Program Files (x86)\Google\google_appengine\lib\django\django\template\defaulttags.py", line 175, in render
-
return self.nodelist_true.render(context)
-
File "C:\Program Files (x86)\Google\google_appengine\lib\django\django\template\__init__.py", line 705, in render
-
bits.append(self.render_node(node, context))
-
File "C:\Program Files (x86)\Google\google_appengine\lib\django\django\template\__init__.py", line 718, in render_node
-
return(node.render(context))
-
File "C:\Program Files (x86)\Google\google_appengine\lib\django\django\template\defaulttags.py", line 99, in render
-
values = list(values)
-
TypeError: 'Greeting' object is not iterable
-
3 29292 bvdet 2,851
Recognized Expert Moderator Specialist
It would help if you posted the error message including the traceback.
The assignments you make in LoginBar() don't seem right. You make an assignment to info twice before the if statement, and then again if user evaluates True.
The second block of code posted is not valid Python and would raise a SyntaxError.
I added the tracebook, sorry, meant to add that. The last block of code is integrating the python into html, I was half asleep when I asked this, sorry
Never mind, it works now...it turns out I needed to put .all onto the iterating object in the for loop. Thanks for your help!
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Nick Jacobson |
last post by:
Casting an 'enumerate' object destroys it?? Is that supposed to
happen, or is it a bug?
For example:
a =
e = enumerate(a)
print dict(e)
print dict(e)
|
by: Chris Lasher |
last post by:
Hello,
I really like the finditer() method of the re module. I'm having
difficulty at the moment, however, because finditer() still creates a
callable-iterator oject, even when no match is found. This is
undesirable in cases where I would like to circumvent execution of code
meant to parse out data from my finditer() object.
I know that if I place a finditer() object in an iterative for loop,
the loop will not execute, but is there some...
|
by: Leif K-Brooks |
last post by:
Is there a word for an iterable object which isn't also an iterator, and
therefor can be iterated over multiple times without being exhausted?
"Sequence" is close, but a non-iterator iterable could technically
provide an __iter__ method without implementing the sequence protocol,
so it's not quite right.
|
by: Michele Simionato |
last post by:
According to the standand library
(http://docs.python.org/lib/typeiter.html)
an *iterable* is something with an __iter__ method. This means that
strings
are *not* iterable. However I can loop over a string without problem
and I would
say that an iterable is anything I can iterate over. Of course I am
*not* proposing
we add __iter__ to strings (it is convenient for me to be able to
distinguish
|
by: py |
last post by:
I have function which takes an argument. My code needs that argument
to be an iterable (something i can loop over)...so I dont care if its a
list, tuple, etc. So I need a way to make sure that the argument is an
iterable before using it. I know I could do...
def foo(inputVal):
if isinstance(inputVal, (list, tuple)):
for val in inputVal:
# do stuff
| |
by: Tim N. van der Leeuw |
last post by:
Hi,
I'd like to know if there's a way to check if an object is a sequence,
or an iterable. Something like issequence() or isiterable().
Does something like that exist? (Something which, in case of iterable,
doesn't consume the first element of the iterable)
Regards,
|
by: tom |
last post by:
Hi!
My code is
And it gives following error:
How can sortedList variable turn into NoneType? I just don't get it...
|
by: python101 |
last post by:
I try to calculate the sum of an infinite series
S = Sum (from n=0 to 100) 1/k!
I got message 'float' / 'int' object is not iterable. How can I fix this?
|
by: Erich |
last post by:
Hello all,
Today I found myself once again defining two functions that I use all
the time: nsplit and iterable. These little helper functions of mine
get used all the time when I work. Im sick of having to define them
(but am very good at it these days, less than 1 typo per function!).
It leads me to the following questions
1. Is this functionality already built in and im just missing it
2. Is there some well known, good technique...
|
by: mmiikkee13 |
last post by:
>>a_list = range(37)
.... print k, v
....
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: 'int' object is not iterable
What 'int' object is this referring to? I'm iterating over a dict, not
an int.
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
| |
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |