Skip to content


Subversion checkout URL

You can clone with
Download ZIP


Comment._get_userinfo thread safe #50

merged 1 commit into from

2 participants


This pull request is a small fix for Comment._get_userinfo of the django.contrib.comments app. The code was not re-entrant, normally this should not required but I had to fix it because of this other issue in django-debug-toolbar: django-debug-toolbar/django-debug-toolbar#281


Seems like a good idea regardless of threadsafety, now the dict won't be partially populated if an exception occurs.

@alex alex merged commit 1b05546 into django:master

indeed that's the real reason, thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on May 8, 2012
  1. @duilio
This page is out of date. Refresh to see the latest.
Showing with 5 additions and 4 deletions.
  1. +5 −4 django/contrib/comments/
9 django/contrib/comments/
@@ -92,7 +92,7 @@ def _get_userinfo(self):
This dict will have ``name``, ``email``, and ``url`` fields.
if not hasattr(self, "_userinfo"):
- self._userinfo = {
+ userinfo = {
"name" : self.user_name,
"email" : self.user_email,
"url" : self.user_url
@@ -100,15 +100,16 @@ def _get_userinfo(self):
if self.user_id:
u = self.user
- self._userinfo["email"] =
+ userinfo["email"] =
# If the user has a full name, use that for the user name.
# However, a given user_name overrides the raw user.username,
# so only use that if this comment has no associated name.
if u.get_full_name():
- self._userinfo["name"] = self.user.get_full_name()
+ userinfo["name"] = self.user.get_full_name()
elif not self.user_name:
- self._userinfo["name"] = u.username
+ userinfo["name"] = u.username
+ self._userinfo = userinfo
return self._userinfo
userinfo = property(_get_userinfo, doc=_get_userinfo.__doc__)
Something went wrong with that request. Please try again.