Temporary fix:

It appears to be a result of changeset [12637] in memcached.py:
http://code.djangoproject.com/changeset/12637

# memcached.py, lines 53-54 removed in def set()
53:  if isinstance(value, unicode):
54:    value = value.encode('utf-8')

In my templates at least, this means that before 12637, memcached.py
converted the data from <class 'django.utils.safestring.SafeUnicode'>
to <class 'django.utils.safestring.SafeString> before saving it. It no
longer does this conversion, which appears to be necessary at least
for some users.

I was able to fix it by adding those two lines back in to
memcached.py, so the data is converted before the cache attempts to
save it.

Not to familiar with memcached - any reason it wouldn't be able to
digest the unconverted data? I can't tell if this is something that
was overlooked when 12637 was adopted, or whether Willem and I have
something wrong with our caches...

On Apr 5, 10:48 am, Daniel Roseman <dan...@roseman.org.uk> wrote:
> On Apr 5, 11:53 am, Willem <mati...@gmail.com> wrote:
>
>
>
> > Thanks DR -- see below
>
> > class ProfileManager(models.Manager):
>
> >     def recently_added_people(self):
> >         cache_key = 'recently_added_people'
> >         profile_list = cache.get(cache_key)
> >         if profile_list is None:
> >             list = Profile.objects.order_by('-id').filter(
> >                     Q(user__is_active='1')
> >                     )[0:5]
> >             profile_list = []
> >             for profile in list:
> >                 profile_list.append({
> >                     'last_name' : profile.user.last_name,
> >                     })
> >             cache.set(cache_key, profile_list)
> >         return profile_list
>
> > class Profile(models.Model):
> >     user = models.ForeignKey(User, unique=True)   # unique = True is
> > so that 1:1 Profile:User
> > #
> > #  .. deleted some lines here
> > #
> >     temp1       = models.CharField(max_length=40, blank=True)
>
> >     def __unicode__(self):
> >         return u"%s - %s" % (self.user, self.country)
> >     objects = ProfileManager()    # custom
>
> I must say this is a confusing one. What happens if you replace
> 'country' with 'country_code' as the final argument in the {% cache %}
> templatetag?
>
> Also I'm not sure of the relevance of the Manager you post above - is
> that called from this code anywhere?
> --
> DR.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to