I'm new to Python. Am I doing it right?
The goal:
Get a bunch of
InCart
objects from Google App Engine's datastore that corresponds to the current user. EachInCart
item has two attributes:InCart.owner
andInCart.item
Provide the templating engine a set of items in any
InCart.item
The code:
cartEntries = InCart.gql("WHERE owner = :1", self.user)
items = []
for entry in cartEntries:
items.append(entry.item)
if items:
render('Views/table.html', self, {'items': items})
else:
render('Views/message.html', self, {'msg': 'Your cart is empty.'})
This appears to work in my extremely brief testing. How am I doing in terms of style, code clarity, brevity, stability, etc?