String value with spaces like "Hello world" gives MemcachedKeyCharacterError: Control characters not allowed. As far as I see, django-settings trying to create key ':1:Hello world' which contains spaces and not allowed by Memcached.
Traceback:
File "/home/rblack/virtualenvs/protect3/local/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
response = callback(request, _callback_args, *_callback_kwargs)
File "/home/rblack/virtualenvs/protect3/local/lib/python2.7/site-packages/django/contrib/admin/options.py" in wrapper
return self.admin_site.admin_view(view)(_args, *_kwargs)
File "/home/rblack/virtualenvs/protect3/local/lib/python2.7/site-packages/django/utils/decorators.py" in _wrapped_view
response = view_func(request, _args, *_kwargs)
File "/home/rblack/virtualenvs/protect3/local/lib/python2.7/site-packages/django/views/decorators/cache.py" in _wrapped_view_func
response = view_func(request, _args, *_kwargs)
File "/home/rblack/virtualenvs/protect3/local/lib/python2.7/site-packages/django/contrib/admin/sites.py" in inner
return view(request, _args, *_kwargs)
File "/home/rblack/virtualenvs/protect3/local/lib/python2.7/site-packages/django/utils/decorators.py" in _wrapper
return bound_func(_args, *_kwargs)
File "/home/rblack/virtualenvs/protect3/local/lib/python2.7/site-packages/django/utils/decorators.py" in _wrapped_view
response = view_func(request, _args, *_kwargs)
File "/home/rblack/virtualenvs/protect3/local/lib/python2.7/site-packages/django/utils/decorators.py" in bound_func
return func(self, _args2, *_kwargs2)
File "/home/rblack/virtualenvs/protect3/local/lib/python2.7/site-packages/django/db/transaction.py" in inner
return func(_args, *_kwargs)
File "/home/rblack/virtualenvs/protect3/local/lib/python2.7/site-packages/django/contrib/admin/options.py" in change_view
new_object = self.save_form(request, form, change=True)
File "/home/rblack/virtualenvs/protect3/local/lib/python2.7/site-packages/django/contrib/admin/options.py" in save_form
return form.save(commit=False)
File "/home/rblack/virtualenvs/protect3/local/lib/python2.7/site-packages/django_settings/forms.py" in save
return self.setting_changed(instance)
File "/home/rblack/virtualenvs/protect3/local/lib/python2.7/site-packages/django_settings/forms.py" in setting_changed
django_settings.DataAPI.setting_changed(instance)
File "/home/rblack/virtualenvs/protect3/local/lib/python2.7/site-packages/django_settings/dataapi.py" in setting_changed
inst._set_cache_for(new_setting.name, new_setting.setting_object.value)
File "/home/rblack/virtualenvs/protect3/local/lib/python2.7/site-packages/django_settings/dataapi.py" in _set_cache_for
self.get._cache_set(value, name)
File "/home/rblack/virtualenvs/protect3/local/lib/python2.7/site-packages/django_settings/cache.py" in _cache_set
self.cache.set(key, origin_value)
File "/home/rblack/virtualenvs/protect3/local/lib/python2.7/site-packages/django/core/cache/backends/memcached.py" in set
self._cache.set(key, value, self._get_memcache_timeout(timeout))
File "/home/rblack/virtualenvs/protect3/local/lib/python2.7/site-packages/memcache.py" in set
return self._set("set", key, val, time, min_compress_len)
File "/home/rblack/virtualenvs/protect3/local/lib/python2.7/site-packages/memcache.py" in _set
self.check_key(key)
File "/home/rblack/virtualenvs/protect3/local/lib/python2.7/site-packages/memcache.py" in check_key
"Control characters not allowed")
Exception Type: MemcachedKeyCharacterError at /admin/django_settings/setting/19/
Exception Value: Control characters not allowed
The real bug was that DataAPI._set_cache_for method was changing the order of name and value and was creating cache key from value instead of name. var 1.3-7 fixes that.
String value with spaces like "Hello world" gives MemcachedKeyCharacterError: Control characters not allowed. As far as I see, django-settings trying to create key ':1:Hello world' which contains spaces and not allowed by Memcached.
Traceback: Environment:
Request Method: POST Request URL: http://127.0.0.1:8000/admin/django_settings/setting/19/
Django Version: 1.5.2 Python Version: 2.7.4 Installed Applications: ('admin_tools', 'admin_tools.theming', 'admin_tools.menu', 'admin_tools.dashboard', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'raven.contrib.django.raven_compat', 'djcelery', 'south', 'django_settings', 'django.contrib.admin', 'common', 'exodus', 'easy_thumbnails', 'gunicorn') Installed Middleware: ('django.middleware.cache.UpdateCacheMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.locale.LocaleMiddleware', 'django.middleware.common.CommonMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.cache.FetchFromCacheMiddleware')
Traceback: File "/home/rblack/virtualenvs/protect3/local/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
Exception Type: MemcachedKeyCharacterError at /admin/django_settings/setting/19/ Exception Value: Control characters not allowed