Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unicode site title breaks CKAN #288

Merged
merged 1 commit into from
Mar 19, 2013
Merged

Conversation

tobes
Copy link
Contributor

@tobes tobes commented Mar 15, 2013

We are using CKAN v1.8 and we noticed that if we use a site title that contains greek characters, an exception is thrown:

UnicodeDecodeError: 'ascii' codec can't decode byte 0xce in position 0: ordinal not in range(128)

In our local installation we managed to overcome this by 'overriding' every template file that used the site title. You might use the unicode() function to output the string correctly

@tobes
Copy link
Contributor

tobes commented Jan 20, 2013

This also affects 2.0. The following patch worked for me I'm not sure why the config is latin-1 not utf-8 does anyone know why this is?

diff --git a/ckan/lib/app_globals.py b/ckan/lib/app_globals.py
index f93a11e..d478f5e 100644
--- a/ckan/lib/app_globals.py
+++ b/ckan/lib/app_globals.py
@@ -110,6 +110,8 @@ def reset():
         # we want to store the config the first time we get here so we can
         # reset them if needed
         config_value = config.get(key)
+        if config_value:
+            config_value = config_value.decode('latin-1')
         if key not in _CONFIG_CACHE:
             _CONFIG_CACHE[key] = config_value
         if value is not None:

@davidread
Copy link
Contributor

paste/deploy/loadwsgi.py just opens the file and calls ConfigParser.readfp() when it could be decoded as UTF8 first: http://stackoverflow.com/questions/1648517/configparser-with-unicode-items so you might solve this with a monkey patch to paste. Or probably easier to just do what you've done here...

rossjones added a commit to datagovuk/ckan that referenced this pull request Feb 5, 2013
@tobes
Copy link
Contributor

tobes commented Feb 19, 2013

@kindly
I think we should fix this as in my above patch and backport - does that seem the correct approach if so the I'll do a pull request etc and get adria to backport

@tobes
Copy link
Contributor

tobes commented Mar 14, 2013

@kindly @amercader This looks like we should fix and get it into 2.0 are there objections to my patch above? should I make it a pull request

@amercader
Copy link
Member

@tobes go for it. Will this support all unicode characters? (eg ckan.site_title = हाय बिल्लियों)

@tobes
Copy link
Contributor

tobes commented Mar 15, 2013

@amercader I have changed this to also work with unicode as far as I can tell it is all good please consider for 2.0 thanks.
code here now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants