Google app engine tells me to optimize this code. Anybody any ideas what I could do?
def index(request):
user = users.get_current_user()
return base.views.render('XXX.html',
dict(profiles=Profile.gql("").fetch(limit=100), user=user))
And later in the template I do:
{% for profile in profiles %}
<a href="/profile/{{profile.user.email}}/"><img src="{{profile.gravatarUrl}}"></a>
<a href="/profile/{{profile.user.email}}/">{{ profile.user.nickname }}</a>
<br/>{{ profile.shortDisplay }}
Where the methods used are:
def shortDisplay(self):
return "%s/day; %s/week; %s days" % (self.maxPerDay, self.maxPerWeek, self.days)
def gravatarUrl(self):
email = self.user.email().lower()
default = "..."
gravatar_url = "http://www.gravatar.com/avatar.php?"
gravatar_url += urllib.urlencode({'gravatar_id':hashlib.md5(email).hexdigest(),
'default':default, 'size':"64"})
return gravatar_url