aldryn/aldryn-forms — pull request #22 by bastiW (2014-08-27 01:43:42+00:00)
Title: Added UTF-8 support

With the old code i had the following error:

```
UnicodeEncodeError at /de/forms/

'ascii' codec can't encode characters in position 0-2: ordinal not in range(128)

Request Method:	POST
Request URL:	http://127.0.0.1:8000/de/forms/
Django Version:	1.6.5
Exception Type:	UnicodeEncodeError
Exception Value:

'ascii' codec can't encode characters in position 0-2: ordinal not in range(128)

Exception Location:	C:\Users\Sebastian\workspace\env\lib\site-packages\aldryn_forms\models.py in set_form_data, line 187
Python Executable:	C:\Users\Sebastian\workspace\env\Scripts\python.exe
Python Version:	2.7.8
Python Path:

['C:\\Users\\Sebastian\\workspace',
'c:\\users\\sebastian\\workspace\\env\\src\\django-polls',
'C:\\Users\\Sebastian\\workspace\\env\\lib\\site-packages\\cmsplugin_contact-1.0.1-py2.7.egg',
'C:\\Users\\Sebastian\\workspace',
'C:\\WINDOWS\\SYSTEM32\\python27.zip',
'C:\\Users\\Sebastian\\workspace\\env\\DLLs',
'C:\\Users\\Sebastian\\workspace\\env\\lib',
'C:\\Users\\Sebastian\\workspace\\env\\lib\\plat-win',
'C:\\Users\\Sebastian\\workspace\\env\\lib\\lib-tk',
'C:\\Users\\Sebastian\\workspace\\env\\Scripts',
'C:\\Python27\\Lib',
'C:\\Python27\\DLLs',
'C:\\Python27\\Lib\\lib-tk',
'C:\\Users\\Sebastian\\workspace\\env',
'C:\\Users\\Sebastian\\workspace\\env\\lib\\site-packages']

Server time:	Mi, 27 Aug 2014 03:25:55 +0200

Environment:

Request Method: POST
Request URL: http://127.0.0.1:8000/de/forms/

Django Version: 1.6.5
Python Version: 2.7.8
Installed Applications:
('absolute',
'aldryn_forms',
'captcha',
'emailit',
'cmsplugin_contact',
'hvad',
'aldryn_blog',
'aldryn_common',
'django_select2',
'djangocms_text_ckeditor',
'easy_thumbnails',
'filer',
'taggit',
'djangocms_polls',
'polls',
'djangocms_admin_style',
'djangocms_text_ckeditor',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.admin',
'django.contrib.sites',
'django.contrib.sitemaps',
'django.contrib.staticfiles',
'django.contrib.messages',
'cms',
'mptt',
'menus',
'south',
'sekizai',
'djangocms_style',
'djangocms_column',
'djangocms_file',
'djangocms_flash',
'djangocms_googlemap',
'djangocms_inherit',
'djangocms_link',
'djangocms_picture',
'djangocms_teaser',
'djangocms_video',
'reversion',
'mysite')
Installed Middleware:
('django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.locale.LocaleMiddleware',
'django.middleware.doc.XViewMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'cms.middleware.user.CurrentUserMiddleware',
'cms.middleware.page.CurrentPageMiddleware',
'cms.middleware.toolbar.ToolbarMiddleware',
'cms.middleware.language.LanguageCookieMiddleware')

Traceback:
File "C:\Users\Sebastian\workspace\env\lib\site-packages\django\core\handlers\base.py" in get_response
112. response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "C:\Users\Sebastian\workspace\env\lib\site-packages\cms\utils\decorators.py" in inner
16. return func(request, *args, **kwargs)
File "C:\Users\Sebastian\workspace\env\lib\site-packages\aldryn_forms\views.py" in submit_form_view
44. form = form_plugin_instance.process_form(form_plugin, request)
File "C:\Users\Sebastian\workspace\env\lib\site-packages\aldryn_forms\cms_plugins.py" in process_form
101. self.form_valid(instance, request, form)
File "C:\Users\Sebastian\workspace\env\lib\site-packages\aldryn_forms\cms_plugins.py" in form_valid
81. form.save()
File "C:\Users\Sebastian\workspace\env\lib\site-packages\aldryn_forms\forms.py" in save
30. self.instance.set_form_data(self)
File "C:\Users\Sebastian\workspace\env\lib\site-packages\aldryn_forms\models.py" in set_form_data
187. formatted_data = ['{0}: {1}'.format(*group) for group in grouped_data]

Exception Type: UnicodeEncodeError at /de/forms/
Exception Value: 'ascii' codec can't encode characters in position 0-2: ordinal not in range(128)

Request information
GET

No GET data
POST
Variable	Value
aldryn-forms-field-42

u'from@localhost.com'

form_plugin_id

u'41'

aldryn-forms-field-45

u'message\r\n'

aldryn-forms-field-44

u'\xdf\xf6\xe4'

submit

u'Senden'

csrfmiddlewaretoken

u'VGCiUcYtAgLQFuw4WOXUKMCRgawgsWxs'

FILES

No FILES data
COOKIES
Variable	Value
csrftoken

'VGCiUcYtAgLQFuw4WOXUKMCRgawgsWxs'

sessionid

'8hr4yvox95e6sgsp2z8c2sx54o0bjvis'

django_language

'de'

META
Variable	Value
TMP

'C:\\Users\\SEBAST~1\\AppData\\Local\\Temp'

PYTHONIOENCODING

'UTF-8'

COMPUTERNAME

'YOGABOOK'

wsgi.multiprocess

False

PROCESSOR_LEVEL

'6'

RUN_MAIN

'true'

HTTP_REFERER

'http://127.0.0.1:8000/de/forms/'

USERDOMAIN

'YOGABOOK'

READYAPPS

'C:\\ProgramData\\Lenovo\\ReadyApps'

SERVER_PROTOCOL

'HTTP/1.1'

SERVER_SOFTWARE

'WSGIServer/0.1 Python/2.7.8'

PSMODULEPATH

'C:\\WINDOWS\\system32\\WindowsPowerShell\\v1.0\\Modules\\'

SCRIPT_NAME

u''

COMMONPROGRAMFILES

'C:\\Program Files (x86)\\Common Files'

PROCESSOR_IDENTIFIER

'Intel64 Family 6 Model 69 Stepping 1, GenuineIntel'

REQUEST_METHOD

'POST'

VBOX_MSI_INSTALL_PATH

'C:\\Program Files\\Oracle\\VirtualBox\\'

CYGWIN

'tty'

PROCESSOR_REVISION

'4501'

SYSTEMROOT

'C:\\WINDOWS'

QUERY_STRING

''

PATH

'C:\\Python27\\;C:\\Program Files (x86)\\Intel\\iCLS Client\\;C:\\Program Files\\Intel\\iCLS Client\\;C:\\WINDOWS\\system32;C:\\WINDOWS;C:\\WINDOWS\\System32\\Wbem;C:\\WINDOWS\\System32\\WindowsPowerShell\\v1.0\\;C:\\ProgramData\\Lenovo\\ReadyApps;C:\\Program Files\\Intel\\Intel(R) Management Engine Components\\DAL;C:\\Program Files\\Intel\\Intel(R) Management Engine Components\\IPT;C:\\Program Files (x86)\\Intel\\Intel(R) Management Engine Components\\DAL;C:\\Program Files (x86)\\Intel\\Intel(R) Management Engine Components\\IPT;C:\\Program Files (x86)\\Google\\Google Apps Migration\\;C:\\Program Files\\Intel\\WiFi\\bin\\;C:\\Program Files\\Common Files\\Intel\\WirelessCommon\\;C:\\Program Files\\SlikSvn\\bin;C:\\Program Files (x86)\\Git\\cmd;C:\\Program Files (x86)\\OpenSSH\\bin;C:\\Chocolatey\\bin;C:\\Program Files\\Intel\\WiFi\\bin\\;C:\\Program Files\\Common Files\\Intel\\WirelessCommon\\;"c:\\Program Files\\nodejs";C:\\Python27;C:\\Python27\\Scripts;C:\\Python27\\Tools\\Scripts;C:\\Users\\Sebastian\\workspace\\env\\Scripts'

PYTHONUNBUFFERED

'1'

PROGRAMFILES(X86)

'C:\\Program Files (x86)'

CONTENT_LENGTH

'204'

HTTP_USER_AGENT

'Mozilla/5.0 (Windows NT 6.3; WOW64; rv:31.0) Gecko/20100101 Firefox/31.0'

HTTP_CONNECTION

'keep-alive'

HTTP_COOKIE

'django_language=de; csrftoken=VGCiUcYtAgLQFuw4WOXUKMCRgawgsWxs; sessionid=8hr4yvox95e6sgsp2z8c2sx54o0bjvis'

TEMP

'C:\\Users\\SEBAST~1\\AppData\\Local\\Temp'

REMOTE_ADDR

'127.0.0.1'

TVT

'C:\\Program Files (x86)\\Lenovo'

COMMONPROGRAMFILES(X86)

'C:\\Program Files (x86)\\Common Files'

PROCESSOR_ARCHITECTURE

'x86'

CHOCOLATEYINSTALL

'C:\\Chocolatey'

wsgi.url_scheme

'http'

ALLUSERSPROFILE

'C:\\ProgramData'

SERVER_PORT

'8000'

LOCALAPPDATA

'C:\\Users\\Sebastian\\AppData\\Local'

HOMEPATH

'\\Users\\Sebastian'

USERDOMAIN_ROAMINGPROFILE

'YOGABOOK'

PROGRAMW6432

'C:\\Program Files'

USERNAME

'Sebastian'

HTTP_ACCEPT

'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8'

LOGONSERVER

'\\\\MicrosoftAccount'

COMSPEC

'C:\\WINDOWS\\system32\\cmd.exe'

PROGRAMDATA

'C:\\ProgramData'

PYTHONPATH

'C:\\Users\\Sebastian\\workspace'

PATH_INFO

u'/de/forms/'

wsgi.multithread

True

CSRF_COOKIE

u'VGCiUcYtAgLQFuw4WOXUKMCRgawgsWxs'

wsgi.input

wsgi.errors

', mode 'w' at 0x01C6D0D0>

HTTP_HOST

'127.0.0.1:8000'

SESSIONNAME

'Console'

PATHEXT

'.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC'

CONFIGSETROOT

'C:\\WINDOWS\\ConfigSetRoot'

FP_NO_HOST_CHECK

'NO'

WINDIR

'C:\\WINDOWS'

wsgi.file_wrapper

''

HTTP_ACCEPT_ENCODING

'gzip, deflate'

wsgi.version

(1, 0)

HOMEDRIVE

'C:'

APPDATA

'C:\\Users\\Sebastian\\AppData\\Roaming'

SERVER_NAME

'Yogabook'

PROGRAMFILES

'C:\\Program Files (x86)'

REMOTE_HOST

''

SYSTEMDRIVE

'C:'

GATEWAY_INTERFACE

'CGI/1.1'

HTTP_ACCEPT_LANGUAGE

'de,en-US;q=0.7,en;q=0.3'

PYCHARM_HOSTED

'1'

NUMBER_OF_PROCESSORS

'4'

wsgi.run_once

False

DJANGO_SETTINGS_MODULE

'mysite.settings'

CONTENT_TYPE

'application/x-www-form-urlencoded'

PROCESSOR_ARCHITEW6432

'AMD64'

COMMONPROGRAMW6432

'C:\\Program Files\\Common Files'

OS

'Windows_NT'

PUBLIC

'C:\\Users\\Public'

USERPROFILE

'C:\\Users\\Sebastian'

Settings
Using settings module mysite.settings
Setting	Value
USE_L10N

True

THUMBNAIL_PROCESSORS

('easy_thumbnails.processors.colorspace',
'easy_thumbnails.processors.autocrop',
'filer.thumbnail_processors.scale_and_crop_with_subject_location',
'easy_thumbnails.processors.filters')

USE_THOUSAND_SEPARATOR

False

CSRF_COOKIE_SECURE

False

LANGUAGE_CODE

'de'

ROOT_URLCONF

'mysite.urls'

LOGIN_URL

'/accounts/login/'

BASE_DIR

'C:\\Users\\Sebastian\\workspace'

DEFAULT_CHARSET

'utf-8'

SESSION_SERIALIZER

'django.contrib.sessions.serializers.JSONSerializer'

STATIC_ROOT

'C:\\Users\\Sebastian\\workspace\\static'

ALLOWED_HOSTS

[]

MESSAGE_STORAGE

'django.contrib.messages.storage.fallback.FallbackStorage'

EMAIL_SUBJECT_PREFIX

'[Django] '

SEND_BROKEN_LINK_EMAILS

False

STATICFILES_FINDERS

('django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder')

SESSION_CACHE_ALIAS

'default'

SESSION_COOKIE_DOMAIN

None

SESSION_COOKIE_NAME

'sessionid'

CSRF_COOKIE_NAME

'csrftoken'

ADMIN_FOR

()

TIME_INPUT_FORMATS

('%H:%M:%S', '%H:%M:%S.%f', '%H:%M')

DATABASES

{'default': {'ATOMIC_REQUESTS': False,
'AUTOCOMMIT': True,
'CONN_MAX_AGE': 0,
'ENGINE': 'django.db.backends.sqlite3',
'HOST': 'localhost',
'NAME': 'project.db',
'OPTIONS': {},
'PASSWORD': u'********************',
'PORT': '',
'TEST_CHARSET': None,
'TEST_COLLATION': None,
'TEST_MIRROR': None,
'TEST_NAME': None,
'TIME_ZONE': 'UTC',
'USER': ''}}

FILE_UPLOAD_PERMISSIONS

None

FILE_UPLOAD_HANDLERS

('django.core.files.uploadhandler.MemoryFileUploadHandler',
'django.core.files.uploadhandler.TemporaryFileUploadHandler')

DEFAULT_CONTENT_TYPE

'text/html'

APPEND_SLASH

True

FIRST_DAY_OF_WEEK

0

DATABASE_ROUTERS

[]

YEAR_MONTH_FORMAT

'F Y'

STATICFILES_STORAGE

'django.contrib.staticfiles.storage.StaticFilesStorage'

CACHES

{'default': {'BACKEND': 'django.core.cache.backends.locmem.LocMemCache'}}

SERVER_EMAIL

'root@localhost'

SESSION_COOKIE_PATH

'/'

CMS_TEMPLATES

(('page.html', 'Page'), ('feature.html', 'Page with Feature'))

MIDDLEWARE_CLASSES

('django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.locale.LocaleMiddleware',
'django.middleware.doc.XViewMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'cms.middleware.user.CurrentUserMiddleware',
'cms.middleware.page.CurrentPageMiddleware',
'cms.middleware.toolbar.ToolbarMiddleware',
'cms.middleware.language.LanguageCookieMiddleware')

USE_I18N

True

THOUSAND_SEPARATOR

','

SECRET_KEY

u'********************'

LANGUAGE_COOKIE_NAME

'django_language'

DEFAULT_INDEX_TABLESPACE

''

TRANSACTIONS_MANAGED

False

LOGGING_CONFIG

'django.utils.log.dictConfig'

TEMPLATE_LOADERS

('django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',
'django.template.loaders.eggs.Loader')

WSGI_APPLICATION

'mysite.wsgi.application'

TEMPLATE_DEBUG

True

X_FRAME_OPTIONS

'SAMEORIGIN'

ALDRYN_BLOG_PLUGIN_LANGUAGE

'de'

FORCE_SCRIPT_NAME

None

USE_X_FORWARDED_HOST

False

SIGNING_BACKEND

'django.core.signing.TimestampSigner'

SESSION_COOKIE_SECURE

False

CSRF_COOKIE_DOMAIN

None

FILE_CHARSET

'utf-8'

DEBUG

True

SESSION_FILE_PATH

None

DEFAULT_FILE_STORAGE

'django.core.files.storage.FileSystemStorage'

INSTALLED_APPS

('absolute',
'aldryn_forms',
'captcha',
'emailit',
'cmsplugin_contact',
'hvad',
'aldryn_blog',
'aldryn_common',
'django_select2',
'djangocms_text_ckeditor',
'easy_thumbnails',
'filer',
'taggit',
'djangocms_polls',
'polls',
'djangocms_admin_style',
'djangocms_text_ckeditor',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.admin',
'django.contrib.sites',
'django.contrib.sitemaps',
'django.contrib.staticfiles',
'django.contrib.messages',
'cms',
'mptt',
'menus',
'south',
'sekizai',
'djangocms_style',
'djangocms_column',
'djangocms_file',
'djangocms_flash',
'djangocms_googlemap',
'djangocms_inherit',
'djangocms_link',
'djangocms_picture',
'djangocms_teaser',
'djangocms_video',
'reversion',
'mysite')

LANGUAGES_BIDI

('he', 'ar', 'fa', 'ur')

COMMENTS_ALLOW_PROFANITIES

False

STATICFILES_DIRS

('C:\\Users\\Sebastian\\workspace\\mysite\\static',)

PREPEND_WWW

False

SECURE_PROXY_SSL_HEADER

None

SESSION_COOKIE_HTTPONLY

True

DEBUG_PROPAGATE_EXCEPTIONS

False

INTERNAL_IPS

()

EMAIL_FILE_PATH

'C:/Users/Sebastian/workspace/mail'

MONTH_DAY_FORMAT

'F j'

MANAGERS

()

SESSION_EXPIRE_AT_BROWSER_CLOSE

False

TIME_FORMAT

'P'

AUTH_USER_MODEL

'auth.User'

DATE_INPUT_FORMATS

('%Y-%m-%d',
'%m/%d/%Y',
'%m/%d/%y',
'%b %d %Y',
'%b %d, %Y',
'%d %b %Y',
'%d %b, %Y',
'%B %d %Y',
'%B %d, %Y',
'%d %B %Y',
'%d %B, %Y')

AUTHENTICATION_BACKENDS

('django.contrib.auth.backends.ModelBackend',)

EMAIL_HOST_PASSWORD

u'********************'

PASSWORD_RESET_TIMEOUT_DAYS

u'********************'

CACHE_MIDDLEWARE_ALIAS

'default'

SESSION_SAVE_EVERY_REQUEST

False

NUMBER_GROUPING

0

SESSION_ENGINE

'django.contrib.sessions.backends.db'

CSRF_FAILURE_VIEW

'django.views.csrf.csrf_failure'

CSRF_COOKIE_PATH

'/'

LOGIN_REDIRECT_URL

'/accounts/profile/'

DECIMAL_SEPARATOR

'.'

IGNORABLE_404_URLS

()

LOCALE_PATHS

()

CMS_PLACEHOLDER_CONF

{}

TEMPLATE_STRING_IF_INVALID

''

DISALLOWED_USER_AGENTS

()

LOGOUT_URL

'/accounts/logout/'

EMAIL_USE_TLS

False

FIXTURE_DIRS

()

EMAIL_HOST

'localhost'

DATE_FORMAT

'N j, Y'

MEDIA_ROOT

'C:\\Users\\Sebastian\\workspace\\media'

DEFAULT_EXCEPTION_REPORTER_FILTER

'django.views.debug.SafeExceptionReporterFilter'

ADMINS

()

FORMAT_MODULE_PATH

None

DEFAULT_FROM_EMAIL

's.weiss@bamoo.de'

MEDIA_URL

'/media/'

DATETIME_FORMAT

'N j, Y, P'

TEMPLATE_DIRS

('C:\\Users\\Sebastian\\workspace\\mysite\\templates',)

SITE_ID

1

CMS_PERMISSION

True

ALLOWED_INCLUDE_ROOTS

()

LOGGING

{}

SHORT_DATE_FORMAT

'm/d/Y'

CMS_LANGUAGES

{1: [{'code': 'de',
'fallbacks': ['en'],
'hide_untranslated': False,
'name': 'de',
'public': True,
'redirect_on_fallback': True},
{'code': 'en',
'fallbacks': ['de'],
'hide_untranslated': False,
'name': 'en',
'public': True,
'redirect_on_fallback': True}],
: True,
'default': {'hide_untranslated': False,
'public': True,
'redirect_on_fallback': True}}

TEST_RUNNER

'django.test.runner.DiscoverRunner'

CACHE_MIDDLEWARE_KEY_PREFIX

u'********************'

TIME_ZONE

'Europe/Berlin'

SOUTH_MIGRATION_MODULES

{'easy_thumbnails': 'easy_thumbnails.south_migrations'}

FILE_UPLOAD_MAX_MEMORY_SIZE

2621440

EMAIL_BACKEND

'django.core.mail.backends.filebased.EmailBackend'

DEFAULT_TABLESPACE

''

TEMPLATE_CONTEXT_PROCESSORS

('django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
'django.core.context_processors.i18n',
'django.core.context_processors.debug',
'django.core.context_processors.request',
'django.core.context_processors.media',
'django.core.context_processors.csrf',
'django.core.context_processors.tz',
'sekizai.context_processors.sekizai',
'django.core.context_processors.static',
'cms.context_processors.cms_settings')

SESSION_COOKIE_AGE

1209600

SETTINGS_MODULE

'mysite.settings'

USE_ETAGS

False

LANGUAGES

(('de', 'de'), ('en', 'en'))

FILE_UPLOAD_TEMP_DIR

None

ALDRYN_BLOG_SEARCH

True

STATIC_URL

'/static/'

EMAIL_PORT

25

USE_TZ

True

SHORT_DATETIME_FORMAT

'm/d/Y P'

PASSWORD_HASHERS

u'********************'

ABSOLUTE_URL_OVERRIDES

{}

CACHE_MIDDLEWARE_SECONDS

600

CSRF_COOKIE_HTTPONLY

False

DATETIME_INPUT_FORMATS

('%Y-%m-%d %H:%M:%S',
'%Y-%m-%d %H:%M:%S.%f',
'%Y-%m-%d %H:%M',
'%Y-%m-%d',
'%m/%d/%Y %H:%M:%S',
'%m/%d/%Y %H:%M:%S.%f',
'%m/%d/%Y %H:%M',
'%m/%d/%Y',
'%m/%d/%y %H:%M:%S',
'%m/%d/%y %H:%M:%S.%f',
'%m/%d/%y %H:%M',
'%m/%d/%y')

EMAIL_HOST_USER

''

PROFANITIES_LIST

u'********************'
```