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

NoneType object has no attribute split #69

Closed
mbrochh opened this issue Mar 8, 2013 · 8 comments
Closed

NoneType object has no attribute split #69

mbrochh opened this issue Mar 8, 2013 · 8 comments

Comments

@mbrochh
Copy link

mbrochh commented Mar 8, 2013

Hi all,

I'm using Django 1.4 and rosetta 0.6.8.

Somehow when I translate a few entries and click at the save button a few times, or even when I just click at the paginator links, after a few clicks I end up with this error message.

The problem can be resolved by restarting Apache.

Does anyone know what could be causing this?

@mbi
Copy link
Owner

mbi commented Mar 8, 2013

Okay, do you know which file has that problem? Do you have a complete stacktrace? If so, could you please paste it here?

Also, Rosetta 0.7.1 was released, could you please try to upgrade and see if the problem disappears?

@mbrochh
Copy link
Author

mbrochh commented Mar 8, 2013

Ok I just updated to 0.7.1

One other thing I noticed: Clicking the paginators kind of worked now but after about 4 clicks I would end up on the home page again. After just clicking "Save and translate next block" for 4 or 5 times, I finally got this error again:

Environment:


Request Method: POST
Request URL: http://localhost:8000/rosetta/?page=6

Django Version: 1.4.3
Python Version: 2.7.3
Installed Applications:
['buildee',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.sites',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'django.contrib.admin',
 'django.contrib.admindocs',
 'django.contrib.sitemaps',
 'multilingual_project_blog',
 'django_extensions',
 'django_libs',
 'south',
 'rosetta',
 'document_library',
 'hero_slider',
 'multilingual_events',
 'people',
 'roadmap',
 'cms',
 'sekizai',
 'mptt',
 'menus',
 'cms.plugins.text',
 'cms.plugins.link',
 'cms.plugins.snippet',
 'cms.plugins.googlemap',
 'cmsplugin_link_extended',
 'cmsplugin_blog',
 'djangocms_utils',
 'simple_translation',
 'tagging',
 'missing',
 'cmsplugin_blog_categories',
 'cmsplugin_blog_images',
 'cmsplugin_blog_authors',
 'tagging_translated',
 'filer',
 'cmsplugin_filer_file',
 'cmsplugin_filer_image',
 'cmsplugin_filer_folder',
 'easy_thumbnails',
 'cmsplugin_filer_image_translated',
 'debug_toolbar']
Installed Middleware:
['johnny.middleware.LocalStoreClearMiddleware',
 'johnny.middleware.QueryCacheMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'multilingual_project_blog.middleware.SwitchLanguageMiddleware',
 'multilingual_project_blog.middleware.CanonicalURLMiddleware',
 'cms.middleware.multilingual.MultilingualURLMiddleware',
 'cms.middleware.page.CurrentPageMiddleware',
 'cms.middleware.user.CurrentUserMiddleware',
 'cms.middleware.toolbar.ToolbarMiddleware',
 'simple_translation.middleware.MultilingualGenericsMiddleware',
 'cmsplugin_blog.middleware.MultilingualBlogEntriesMiddleware',
 'debug_toolbar.middleware.DebugToolbarMiddleware']


Traceback:
File "/Users/martin/Envs/buildee/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
  117.                             response = middleware_method(request, e)
File "/Users/martin/Envs/buildee/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
  111.                         response = callback(request, *callback_args, **callback_kwargs)
File "/Users/martin/Envs/buildee/lib/python2.7/site-packages/django/views/decorators/cache.py" in _wrapped_view_func
  89.         response = view_func(request, *args, **kwargs)
File "/Users/martin/Envs/buildee/lib/python2.7/site-packages/django/contrib/auth/decorators.py" in _wrapped_view
  20.                 return view_func(request, *args, **kwargs)
File "/Users/martin/Envs/buildee/lib/python2.7/site-packages/rosetta/views.py" in home
  57.         rosetta_i18n_lang_bidi = rosetta_i18n_lang_code.split('-')[0] in settings.LANGUAGES_BIDI

Exception Type: AttributeError at /rosetta/
Exception Value: 'NoneType' object has no attribute 'split'

Once the error appeared, it stays there.

I restarted apache and tried again. This time it took 25 clicks before it happened.

So I put a try except block around the line (57) and put a breakpoint into the except block. Then I restarted the apache server and clicked until the error happend. But this time it was a different error:

'NoneType' object has no attribute 'replace'
In template /Users/martin/Envs/buildee/lib/python2.7/site-packages/rosetta/templates/rosetta/pofile.html, error at line 18
{% block pagetitle %}{{block.super}} - {{rosetta_settings.MESSAGES_SOURCE_LANGUAGE_NAME}} - {{rosetta_i18n_lang_name}} ({{ rosetta_i18n_pofile.percent_translated|floatformat:0 }}%){% endblock %}

Traceback:
File "/Users/martin/Envs/buildee/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
  117.                             response = middleware_method(request, e)
File "/Users/martin/Envs/buildee/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
  111.                         response = callback(request, *callback_args, **callback_kwargs)
File "/Users/martin/Envs/buildee/lib/python2.7/site-packages/django/views/decorators/cache.py" in _wrapped_view_func
  89.         response = view_func(request, *args, **kwargs)
File "/Users/martin/Envs/buildee/lib/python2.7/site-packages/django/contrib/auth/decorators.py" in _wrapped_view
  20.                 return view_func(request, *args, **kwargs)
File "/Users/martin/Envs/buildee/lib/python2.7/site-packages/rosetta/views.py" in home
  268.         ), context_instance=RequestContext(request))
File "/Users/martin/Envs/buildee/lib/python2.7/site-packages/django/shortcuts/__init__.py" in render_to_response
  20.     return HttpResponse(loader.render_to_string(*args, **kwargs), **httpresponse_kwargs)
File "/Users/martin/Envs/buildee/lib/python2.7/site-packages/django/template/loader.py" in render_to_string
  176.         return t.render(context_instance)
File "/Users/martin/Envs/buildee/lib/python2.7/site-packages/django/template/base.py" in render
  140.             return self._render(context)
File "/Users/martin/Envs/buildee/lib/python2.7/site-packages/django/test/utils.py" in instrumented_test_render
  62.     return self.nodelist.render(context)
File "/Users/martin/Envs/buildee/lib/python2.7/site-packages/django/template/base.py" in render
  823.                 bit = self.render_node(node, context)
File "/Users/martin/Envs/buildee/lib/python2.7/site-packages/django/template/debug.py" in render_node
  74.             return node.render(context)
File "/Users/martin/Envs/buildee/lib/python2.7/site-packages/django/template/loader_tags.py" in render
  123.         return compiled_parent._render(context)
File "/Users/martin/Envs/buildee/lib/python2.7/site-packages/django/test/utils.py" in instrumented_test_render
  62.     return self.nodelist.render(context)
File "/Users/martin/Envs/buildee/lib/python2.7/site-packages/django/template/base.py" in render
  823.                 bit = self.render_node(node, context)
File "/Users/martin/Envs/buildee/lib/python2.7/site-packages/django/template/debug.py" in render_node
  74.             return node.render(context)
File "/Users/martin/Envs/buildee/lib/python2.7/site-packages/django/template/loader_tags.py" in render
  62.             result = block.nodelist.render(context)
File "/Users/martin/Envs/buildee/lib/python2.7/site-packages/django/template/base.py" in render
  823.                 bit = self.render_node(node, context)
File "/Users/martin/Envs/buildee/lib/python2.7/site-packages/django/template/debug.py" in render_node
  74.             return node.render(context)
File "/Users/martin/Envs/buildee/lib/python2.7/site-packages/django/template/debug.py" in render
  87.             output = force_unicode(output)
File "/Users/martin/Envs/buildee/lib/python2.7/site-packages/django/utils/encoding.py" in force_unicode
  71.                 s = unicode(s)
File "/Users/martin/Envs/buildee/lib/python2.7/site-packages/django/utils/functional.py" in __unicode_cast
  121.             return func(*self.__args, **self.__kw)
File "/Users/martin/Envs/buildee/lib/python2.7/site-packages/django/utils/translation/__init__.py" in ugettext
  86.     return _trans.ugettext(message)
File "/Users/martin/Envs/buildee/lib/python2.7/site-packages/django/utils/translation/trans_real.py" in ugettext
  278.     return do_translate(message, 'ugettext')
File "/Users/martin/Envs/buildee/lib/python2.7/site-packages/django/utils/translation/trans_real.py" in do_translate
  261.     eol_message = message.replace('\r\n', '\n').replace('\r', '\n')

This is really weird, at this code rosetta doesn't seem to be involved.

I tried again, this time the breakpoint was hit.

settings.LANGUAGES_BIDI is ('he', 'ar', 'fa')
rosetta_i18n_lang_code is None

I have no idea what these three languages are... my site uses 'en' and 'zh'.

@mbrochh
Copy link
Author

mbrochh commented Mar 8, 2013

From further digging it seems that his has to do something with the cache storage value getting lost. I also found the note about Storages and DJango 1.4 in the README... I will try if setting ROSETTA_STORAGE_CLASS = 'rosetta.storage.CacheRosettaStorage' gets me somewhere...

@mbi
Copy link
Owner

mbi commented Mar 8, 2013

Thanks for the feedback. Yes, please try either the Cache or the Session storage.

Also, what is the value of CACHES in your settings?

@mbrochh
Copy link
Author

mbrochh commented Mar 8, 2013

@mbi I don't think I have any, what should it be?

@mbi
Copy link
Owner

mbi commented Mar 8, 2013

Yes, that's most likely the problem: if you use the CacheBackend you should use a proper cache backend, e.g. Redis or Memcached.

By default Django uses the LocMemem cache backend, which is tied to each server process (and is cycled when the server process is recycled).

Which would explain why everything works for a while and then suddenly breaks.

@mbrochh
Copy link
Author

mbrochh commented Mar 8, 2013

Yea I just changed it to database backend and now it is significantly slower but seems to work. Thanks a lot!

@mbi
Copy link
Owner

mbi commented Mar 8, 2013

Cheers! (You should install memcached if you get a chance)

@mbi mbi closed this as completed Mar 8, 2013
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

No branches or pull requests

2 participants