When on a question page, I get the 'Callback invoke error: error' message on the following actions: 'delete', 'flag offensive', and vote up and vote down.
I would appreciate any pointers on how to resolve this. It seems to be related to using the wrong encoding at some level of the system, but I'm not sure which part. My messages are localized to Arabic, but I'm not mixing languages, so in settings.py
USE_I18N = True
LANGUAGE_CODE = 'ar'
I have included the log from the dev server for a short session:
#$ python manage.py runserver `hostname -i`:8000
/usr/local/lib/python2.6/dist-packages/django/db/__init__.py:19: DeprecationWarning: settings.DATABASE_* is deprecated; use settings.DATABASES instead.
DeprecationWarning
/usr/local/lib/python2.6/dist-packages/django/db/__init__.py:60: DeprecationWarning: Short names for ENGINE in database configurations are deprecated. Prepend default.ENGINE with 'django.db.backends.'
DeprecationWarning
/usr/local/lib/python2.6/dist-packages/django/db/__init__.py:19: DeprecationWarning: settings.DATABASE_* is deprecated; use settings.DATABASES instead.
DeprecationWarning
/usr/local/lib/python2.6/dist-packages/django/db/__init__.py:60: DeprecationWarning: Short names for ENGINE in database configurations are deprecated. Prepend default.ENGINE with 'django.db.backends.'
DeprecationWarning
Validating models...
0 errors found
Django version 1.3.1, using settings 'askbotqa.settings'
Development server is running at http://127.0.1.1:8000/
Quit the server with CONTROL-C.
/usr/local/lib/python2.6/dist-packages/django/contrib/auth/__init__.py:26: DeprecationWarning: Authentication backends without a `supports_object_permissions` attribute are deprecated. Please define it in <class 'askbot.deps.django_authopenid.backends.AuthBackend'>.
DeprecationWarning)
/usr/local/lib/python2.6/dist-packages/django/contrib/auth/__init__.py:31: DeprecationWarning: Authentication backends without a `supports_anonymous_user` attribute are deprecated. Please define it in <class 'askbot.deps.django_authopenid.backends.AuthBackend'>.
DeprecationWarning)
/usr/local/lib/python2.6/dist-packages/django/contrib/auth/models.py:393: DeprecationWarning: The user messaging API is deprecated. Please update your code to use the new messages framework.
category=DeprecationWarning)
/usr/local/lib/python2.6/dist-packages/django/core/context_processors.py:27: DeprecationWarning: The context processor at `django.core.context_processors.auth` is deprecated; use the path `django.contrib.auth.context_processors.auth` instead.
DeprecationWarning
[20/Jan/2012 21:01:06] "GET /%D8%B3%D8%A4%D8%A7%D9%84/3/d-twl-lbhth-n-lls-lhqyqy-lsrq-lhdhy HTTP/1.1" 200 22799
[20/Jan/2012 21:01:07] "GET /m/default/media/style/style.css?v=7 HTTP/1.1" 304 0
[20/Jan/2012 21:01:07] "GET /m/common/media/js/wmd/wmd.css?v=7 HTTP/1.1" 304 0
[20/Jan/2012 21:01:07] "GET /m/common/media/js/jquery-1.4.3.js?v=7 HTTP/1.1" 304 0
[20/Jan/2012 21:01:07] "GET /m/common/media/js/utils.js?v=7 HTTP/1.1" 304 0
[20/Jan/2012 21:01:07] "GET /jsi18n/ HTTP/1.1" 200 13955
[20/Jan/2012 21:01:07] "GET /m/common/media/js/editor.js?v=7 HTTP/1.1" 304 0
[20/Jan/2012 21:01:07] "GET /m/common/media/js/wmd/showdown.js?v=7 HTTP/1.1" 304 0
[20/Jan/2012 21:01:07] "GET /m/common/media/js/wmd/wmd.js?v=7 HTTP/1.1" 304 0
[20/Jan/2012 21:01:07] "GET /m/common/media/js/jquery.validate.min.js?v=7 HTTP/1.1" 304 0
[20/Jan/2012 21:01:07] "GET /m/common/media/js/post.js?v=7 HTTP/1.1" 304 0
Traceback (most recent call last):
File "/usr/local/lib/python2.6/dist-packages/django/core/servers/basehttp.py", line 283, in run
self.result = application(self.environ, self.start_response)
File "/usr/local/lib/python2.6/dist-packages/django/contrib/staticfiles/handlers.py", line 68, in __call__
return self.application(environ, start_response)
File "/usr/local/lib/python2.6/dist-packages/django/core/handlers/wsgi.py", line 272, in __call__
response = self.get_response(request)
File "/usr/local/lib/python2.6/dist-packages/django/core/handlers/base.py", line 146, in get_response
response = debug.technical_404_response(request, e)
File "/usr/local/lib/python2.6/dist-packages/django/views/debug.py", line 294, in technical_404_response
'reason': smart_str(exception, errors='replace'),
File "/usr/local/lib/python2.6/dist-packages/django/utils/encoding.py", line 123, in smart_str
errors) for arg in s])
File "/usr/local/lib/python2.6/dist-packages/django/utils/encoding.py", line 124, in smart_str
return unicode(s).encode(encoding, errors)
UnicodeEncodeError: 'ascii' codec can't encode characters in position 24-29: ordinal not in range(128)
[20/Jan/2012 21:01:42] "POST /%D8%A7%D9%84%D8%A3%D8%B3%D8%A6%D9%84%D8%A9/3/vote/ HTTP/1.1" 500 1202
Fixed this bug in the repository, will be available in 0.7.40.
It was possible to fix this without losing the ability to show unicode urls in the browsers. The downside of using non-ascii characters in the urls is that older browsers won't display them properly.
I will expand a bit on this topic. (Please note in the following that I'm new to the Python/Django scene.)
With regards to the handling of url's and slugs:
the majority of top tier sites do not use url encoding (percent encoding) for the slugs. Some just use English titles, most use articles id's.
few of the top tier sites do use URL encoding for the slugs - some examples (providing them in the ugly encoded form):
http://sayedmokhtar.maktoobblog.com/1633941/%D8%AF%D9%83%D8%AA%D9%88%D8%B1-%D8%B3%D9%8A%D8%AF-%D9%85%D8%AE%D8%AA%D8%A7%D8%B1-%D9%8A%D9%83%D8%AA%D8%A8-%D8%AB%D9%88%D8%B1%D8%A9-%D8%B4%D8%B9%D8%A8%D9%8A%D8%A9-%D9%82%D8%A7%D8%AF%D9%85%D8%A9/
http://fr-fr.facebook.com/pages/%D8%A7%D9%84%D8%AB%D9%88%D8%B1%D8%A9-%D8%A7%D9%84%D8%B4%D8%B9%D8%A8%D9%8A%D8%A9-%D8%A7%D9%84%D9%85%D8%BA%D8%B1%D8%A8%D9%8A%D8%A9-%D8%A7%D9%84%D9%82%D8%A7%D8%AF%D9%85%D8%A9/188865831132687
Using percent encoding with Arabic comes with its pros and cons:
Cons: because of implementation issues and inconsistencies among different browsers, issues arise like:
Pros: would help with SEO (possible)
Now to Askbot; I can see it's using both Romanization for article slugs and percent encoding for the section names in the path segment. I'm not sure where the slugification is happening (Askbot level or Django level) - this is just a sample url from a test site where the encoded segment is the 'questions' section:
http://127.0.1.1:8000/%D8%B3%D8%A4%D8%A7%D9%84/5/brkt-mwzfy-wzrth-lmlyn-fy-mktb-lkhdm-ljtmy
The slugify function is rather crude and removes some characters that don't have latin counterparts, thus it would be better to override it. Informal transliterated writing is in common use for Arabic (and other languages), for example in chat, sms and in cases where there are technical issues - see http://en.wikipedia.org/wiki/Arabic_chat_alphabet - so the slugification option makes good sense, but there are conventions in mapping the letters between the two languages, so it also makes sense that different languages can have different mappings or even different translation functions.
I would also like to have the choice to get rid of percent encoding in the path segment of the URL (because of the url encoding issues mentioned above), and replace it with either a Romanized form or the original English strings (ie 'questions' segment remains the same even when the locale is set to something not English). (not sure how to get the original English strings with gettext, switching locales maybe?!)
So to sum up - this is the list of possible options that different people might consider in multi-lingual, or uni-lingual non-English sites:
For the path section:
For the slug section: (independent from the above)
(of course using id's rather than slugs is also an option.)
Ultimately when IDN's become common and punycode becomes ubiquitous in browsers and implementation issues get straightened out - we probably won't need all this or would need it to a lessor degree as a choice.
I appreciate any comments on the above. If needs be I'll post some of the raised points as separate questions.
Create your Q&A site at askbot.com. Managed Askbot hosting at just $15/mo. Dedicated hosting, support contracts, consulting services.
create your Q&A siteAsked: 2012-01-21 01:50:17 -0500
Seen: 224 times
Last updated: Jan 25 '12
Some page is rendered partially in English and partially in Chinese
Internal Server Error when trying to edit personal pro
Where are the badges in a fresh install? [fixed]
HTML Tags in titles getting eaten <fixed/>
Unknown column 'auth_user.is_approved' in 'field list' [fixed]
email for comments: link missing a href [fixed]
Bug: Horizontal Rule in Comment breaks stylesheet [fixed]
"Related questions" section shows deleted questions?
error on upvote: "Sorry, something is not right here..." [fixed]
Copyright Askbot, 2010-2011. Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.
Could you clarify - where did you obtain the source code for askbot and which version are you using?
Evgeny ( 2012-01-21 06:31:13 -0500 )editThe version is 0.7.38. I obtained it using pip for the the first time, then pip --update later.
Basel Shishani ( 2012-01-21 07:28:41 -0500 )editThe url translation is broken, looking into it now, will be fixed in the next version.
Evgeny ( 2012-01-21 08:01:43 -0500 )editI think we should not be supporting non-ascii urls. I've checked a bunch of non-ascii sites: aljazeera, xinhua, baidu and none of them show unicode characters in the urls. Could you point me to some famous blogs in Arabic? I'd like to know how they handle urls and slugs.
Evgeny ( 2012-01-21 09:17:08 -0500 )edit