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

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to