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

Already on GitHub? Sign in to your account

Cannot import signals (and sometimes get_page_queryset) #275

Closed
dstufft opened this Issue Nov 28, 2009 · 12 comments

Comments

Projects
None yet
3 participants
Contributor

dstufft commented Nov 28, 2009

Randomly it appears my django-cms install would refuse to work and instead throw an unhandle exception. This doesn't happen all the time and the site will be working fine until all of a sudden out of no where it starts throwing exceptions. I cannot figure out what is causing this. I've tried to disable it down to nothing but built in django and cms items and still this error can creep up. Once it starts it doesn't go away until i make a change somewhere in my settings file and then restart django. (Not all changes seem to do it, sometimes commenting out an app, restarting, and the uncommenting it will do it, recently it appears commenting out the cms UserMiddleware seems to be fixing it though.)

This has happened on 2 machines now, one deployed with apache2/mod_wsgi and one deployed on apache2 with fastcgi.

Here are relevant tracebacks.

Traceback (most recent call last):
  File "build/bdist.linux-x86_64/egg/flup/server/fcgi_base.py", line 558, in run
    protocolStatus, appStatus = self.server.handler(self)
  File "build/bdist.linux-x86_64/egg/flup/server/fcgi_base.py", line 1118, in handler
    result = self.application(environ, start_response)
  File "/home/****/projects/cosmetic-md/lib/python2.6/django/core/handlers/wsgi.py", line 241, in __call__
    response = self.get_response(request)
  File "/home/****/projects/cosmetic-md/lib/python2.6/django/core/handlers/base.py", line 73, in get_response
    response = middleware_method(request)
  File "/home/****/projects/cosmetic-md/lib/python2.6/django/middleware/common.py", line 56, in process_request
    if (not _is_valid_path(request.path_info) and
  File "/home/****/projects/cosmetic-md/lib/python2.6/django/middleware/common.py", line 142, in _is_valid_path
    urlresolvers.resolve(path)
  File "/home/****/projects/cosmetic-md/lib/python2.6/django/core/urlresolvers.py", line 303, in resolve
    return get_resolver(urlconf).resolve(path)
  File "/home/****/projects/cosmetic-md/lib/python2.6/django/core/urlresolvers.py", line 216, in resolve
    for pattern in self.url_patterns:
  File "/home/****/projects/cosmetic-md/lib/python2.6/django/core/urlresolvers.py", line 245, in _get_url_patterns
    patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
  File "/home/****/projects/cosmetic-md/lib/python2.6/django/core/urlresolvers.py", line 240, in _get_urlconf_module
    self._urlconf_module = import_module(self.urlconf_name)
  File "/home/****/projects/cosmetic-md/lib/python2.6/django/utils/importlib.py", line 35, in import_module
    __import__(name)
  File "/home/****/projects/cosmetic-md/cosmetic_md/urls.py", line 4, in <module>
    from cms.sitemaps import CMSSitemap
  File "/home/****/projects/cosmetic-md/lib/python2.6/cms/sitemaps/__init__.py", line 1, in <module>
    from cms_sitemap import *
  File "/home/****/projects/cosmetic-md/lib/python2.6/cms/sitemaps/cms_sitemap.py", line 3, in <module>
    from cms.models import Page
  File "/home/****/projects/cosmetic-md/lib/python2.6/cms/models/__init__.py", line 8, in <module>
    from cms import signals
  File "/home/****/projects/cosmetic-md/lib/python2.6/cms/signals.py", line 4, in <module>
    from cms.models import signals as cms_signals, Page, Title
ImportError: cannot import name signals

and

Traceback (most recent call last):
  File "build/bdist.linux-x86_64/egg/flup/server/fcgi_base.py", line 558, in run
    protocolStatus, appStatus = self.server.handler(self)
  File "build/bdist.linux-x86_64/egg/flup/server/fcgi_base.py", line 1118, in handler
    result = self.application(environ, start_response)
  File "/home/****/projects/cosmetic-md/lib/python2.6/django/core/handlers/wsgi.py", line 241, in __call__
    response = self.get_response(request)
  File "/home/****/projects/cosmetic-md/lib/python2.6/django/core/handlers/base.py", line 73, in get_response
    response = middleware_method(request)
  File "/home/****/projects/cosmetic-md/lib/python2.6/cms/middleware/user.py", line 9, in process_request
    from cms.utils.permissions import set_current_user
  File "/home/****/projects/cosmetic-md/lib/python2.6/cms/utils/permissions.py", line 5, in <module>
    from cms.models import Page, PagePermission, GlobalPagePermission
  File "/home/****/projects/cosmetic-md/lib/python2.6/cms/models/__init__.py", line 8, in <module>
    from cms import signals
  File "/home/****/projects/cosmetic-md/lib/python2.6/cms/signals.py", line 4, in <module>
    from cms.models import signals as cms_signals, Page, Title
ImportError: cannot import name signals
Contributor

dstufft commented Nov 28, 2009

Just got another Unhandled Exception, different this time

Traceback (most recent call last):
  File "build/bdist.linux-x86_64/egg/flup/server/fcgi_base.py", line 558, in run
    protocolStatus, appStatus = self.server.handler(self)
  File "build/bdist.linux-x86_64/egg/flup/server/fcgi_base.py", line 1118, in handler
    result = self.application(environ, start_response)
  File "/home/********/projects/cosmetic-md/lib/python2.6/django/core/handlers/wsgi.py", line 241, in __call__
    response = self.get_response(request)
  File "/home/********/projects/cosmetic-md/lib/python2.6/django/core/handlers/base.py", line 73, in get_response
    response = middleware_method(request)
  File "/home/********/projects/cosmetic-md/lib/python2.6/django/middleware/common.py", line 56, in process_request
    if (not _is_valid_path(request.path_info) and
  File "/home/********/projects/cosmetic-md/lib/python2.6/django/middleware/common.py", line 142, in _is_valid_path
    urlresolvers.resolve(path)
  File "/home/********/projects/cosmetic-md/lib/python2.6/django/core/urlresolvers.py", line 303, in resolve
    return get_resolver(urlconf).resolve(path)
  File "/home/********/projects/cosmetic-md/lib/python2.6/django/core/urlresolvers.py", line 216, in resolve
    for pattern in self.url_patterns:
  File "/home/********/projects/cosmetic-md/lib/python2.6/django/core/urlresolvers.py", line 245, in _get_url_patterns
    patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
  File "/home/********/projects/cosmetic-md/lib/python2.6/django/core/urlresolvers.py", line 240, in _get_urlconf_module
    self._urlconf_module = import_module(self.urlconf_name)
  File "/home/********/projects/cosmetic-md/lib/python2.6/django/utils/importlib.py", line 35, in import_module
    __import__(name)
  File "/home/********/projects/cosmetic-md/cosmetic_md/urls.py", line 4, in <module>
    from cms.sitemaps import CMSSitemap
  File "/home/********/projects/cosmetic-md/lib/python2.6/cms/sitemaps/__init__.py", line 1, in <module>
    from cms_sitemap import *
  File "/home/********/projects/cosmetic-md/lib/python2.6/cms/sitemaps/cms_sitemap.py", line 2, in <module>
    from cms.utils.moderator import get_page_queryset
  File "/home/********/projects/cosmetic-md/lib/python2.6/cms/utils/moderator.py", line 4, in <module>
    from cms.models import Page, PageModeratorState, PageModerator, CMSPlugin, Title,\\
  File "/home/********/projects/cosmetic-md/lib/python2.6/cms/models/__init__.py", line 8, in <module>
    from cms import signals
  File "/home/********/projects/cosmetic-md/lib/python2.6/cms/signals.py", line 3, in <module>
    from cms import appresolver
  File "/home/********/projects/cosmetic-md/lib/python2.6/cms/appresolver.py", line 3, in <module>
    from cms.utils.moderator import get_page_queryset
ImportError: cannot import name get_page_queryset
Contributor

DrMeers commented Nov 29, 2009

Can confirm this bug -- has been happening on my installation for a while. Just randomly. Restarting the server fixes it. Example:

[Thu Oct 22 21:15:40 2009] [error] [client 127.0.0.1]   File "/home/.../cms/signals.py", line 3, in <module>
[Thu Oct 22 21:15:40 2009] [error] [client 127.0.0.1]     from cms.models import signals as cms_signals, Page, Title
[Thu Oct 22 21:15:40 2009] [error] [client 127.0.0.1] ImportError: cannot import name signals
Member

digi604 commented Nov 29, 2009

what branch/version is this?

Contributor

dstufft commented Nov 29, 2009

I tried it on trunk, the 2.0.X branch, and the zip that you can download from django-cms.org for 2.0.0

Contributor

DrMeers commented Nov 29, 2009

I'm on master:

commit 3b32886c8d3cb815df3793b3937b2e91d0fb00f1
Author: Patrick Lauber <patrick.lauber@divio.ch>
Date:   Thu Nov 12 16:36:51 2009 +0100
bumped version to 2.0.0.final yeeepeeee :)

It seemed to start in late October. It is very hard to debug because it only occurs rarely for me.

Contributor

dstufft commented Nov 29, 2009

on the one server (using apache2/fcgi) i was getting the error quite frequently, and it would take a lot of screwing around to get it to stop.

Contributor

DrMeers commented Nov 29, 2009

Mine is on a site which is not yet released to the public, so has fairly low traffic at the moment. I'll see if I can pinpoint what leads to its death...

Contributor

dstufft commented Nov 29, 2009

Mine isn't a public site either. It's a remake of a public site on a private subdomain. Just me in the admin panel copying/pasting content from the old site to the new site.

Contributor

DrMeers commented Nov 29, 2009

It does not appear to be consistent -- I just managed to trigger it by moving a page, but then went back and did the same thing again and it did not recur.

Those tracebacks look an awful lot like circular imports...

Contributor

dstufft commented Nov 29, 2009

I started looking at the import statements more, could this have anything to do with it.

cms/signals.py
from cms.models import signals as cms_signals, Page, Title

cms/models/init.py
from moderatormodels import *
from pagemodel import *
from permissionmodels import *
from pluginmodel import *
from titlemodels import *
from cms import signals #Notice This Line

there is also cms/models/signals.py

If cms/signals.py is trying to import signals from cms/models/init.py then it is importing itself. It appears as if cms/signals.py is trying to import Page and Title from cms/models/init.py which i think is what you want, but then cms/signals.py wants cms/models/signals.py and not itself.

Contributor

dstufft commented Nov 30, 2009

http://github.com/dstufft/django-cms-2.0 has a possible fix in cms/models/init.py that repo has 2 changes one to unicode of Page and then the possible fix to this. I'm not 100% sure that the fix is right though, so far I am using it and havn't gotten this error again, and havn't noticed anything else wrong.

Member

digi604 commented Dec 1, 2009

fixed in master and 2.0.X

@christianbertschy christianbertschy pushed a commit to christianbertschy/django-cms-2.0 that referenced this issue Oct 1, 2012

@dstufft dstufft attempt at fixing #275 d43b171

@christianbertschy christianbertschy pushed a commit to christianbertschy/django-cms-2.0 that referenced this issue Oct 1, 2012

@dstufft @digi604 dstufft + digi604 attempt at fixing #275 984f548

This issue was closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment