Help with CommCARE-HQ

Hi Allen,

I’m cc-ing our google group in case any of the other developers have
thoughts on this. In the future please send all questions to this group
(and you should join so you can get updates about the code from other
people!).

So it looks like somewhere in your Django settings you are referencing a
middleware that doesn’t exist.

The main settings file for commcare hq resides in the rapidsms submodule at
lib/rapidsms/webui/settings.py. There you should see a list of middlewares
like:

MIDDLEWARE_CLASSES = [
‘django.middleware.common.CommonMiddleware’,
‘django.contrib.sessions.middleware.SessionMiddleware’,
‘django.middleware.locale.LocaleMiddleware’,
‘django.contrib.auth.middleware.AuthenticationMiddleware’,
]

We also allow you to add middlewares via your settings file (the local.ini
file you should have copied from rapidsms.ini). This is done in the
following section:

[customdjango]
middlewares=hq.middleware.hq.HqMiddleware

Do both of these sections look the same as in your files?

thanks,
Cory

··· On Tue, Jan 26, 2010 at 11:11 AM, Allen Machary wrote:

hi… Cory .,
thanx for the email… got me a bit of an insight on commcare and it’s had
been a big help… but i hav a problem.
I tried to run commcare-hq in my laptop… followed the getting started
from 'http://wiki.github.com/dimagi/commcare-hq/getting-startedhttp://wiki.github.com/dimagi/commcare-hq/getting-started’
the runserver seems to run ok but couldnt view anything… and got this msg

Traceback (most recent call last):

File “/usr/lib/pymodules/python2.6/django/core/servers/basehttp.py”, line 279, in run
self.result = application(self.environ, self.start_response)

File “/usr/lib/pymodules/python2.6/django/core/servers/basehttp.py”, line 651, in call
return self.application(environ, start_response)

File “/usr/lib/pymodules/python2.6/django/core/handlers/wsgi.py”, line 230, in call

self.load_middleware()

File “/usr/lib/pymodules/python2.6/django/core/handlers/base.py”, line 37, in load_middleware
raise exceptions.ImproperlyConfigured, ‘%s isn’t a middleware module’ % middleware_path

ImproperlyConfigured: h isn’t a middleware module

my guess myb commcare is not compatible with the django am using…, hav
this happend to you??

Hi, I just encountered the same problem. It seems to be caused by
RapidSMS not parsing the [customdjango] directives properly. The value
is passed as string rather than an array containing a string, and the
for…in loop at webui/settings.py assuming this is an array - so for
’hq.middleware.hq.HqMiddleware’ it attempts to load module ‘h’, than
module ‘q’ etc…

A quick fix was to add a type check cast the value into an array. I’m
attaching a diff below. Obviously that’s not the ideal fix - the
problem is somewhere in RapidSMS Config class but I didn’t dig too
deep into that…

====================

INJECT RAPIDSMS MIDDLEWARES IF PRESENT

====================

··· - + +if type(RAPIDSMS_CONF["customdjango"]["middlewares"]) == str: + RAPIDSMS_CONF["customdjango"]["middlewares"] = [RAPIDSMS_CONF ["customdjango"]["middlewares"]] + +if type(RAPIDSMS_CONF["customdjango"]["authentications"]) == str: + RAPIDSMS_CONF["customdjango"]["authentications"] = [RAPIDSMS_CONF ["customdjango"]["authentications"]] + if "customdjango" in RAPIDSMS_CONF: if "middlewares" in RAPIDSMS_CONF["customdjango"]: MIDDLEWARE_CLASSES = MIDDLEWARE_CLASSES +\

On Jan 27, 10:52 am, Cory Zue c...@dimagi.com wrote:

Hi Allen,

I’m cc-ing our google group in case any of the other developers have
thoughts on this. In the future please send all questions to this group
(and you should join so you can get updates about the code from other
people!).

So it looks like somewhere in your Django settings you are referencing a
middleware that doesn’t exist.

The main settings file for commcare hq resides in the rapidsms submodule at
lib/rapidsms/webui/settings.py. There you should see a list of middlewares
like:

MIDDLEWARE_CLASSES = [
‘django.middleware.common.CommonMiddleware’,
‘django.contrib.sessions.middleware.SessionMiddleware’,
‘django.middleware.locale.LocaleMiddleware’,
‘django.contrib.auth.middleware.AuthenticationMiddleware’,
]

We also allow you to add middlewares via your settings file (the local.ini
file you should have copied from rapidsms.ini). This is done in the
following section:

[customdjango]
middlewares=hq.middleware.hq.HqMiddleware

Do both of these sections look the same as in your files?

thanks,
Cory

On Tue, Jan 26, 2010 at 11:11 AM, Allen Machary allen.mach...@gmail.comwrote:

hi… Cory .,
thanx for the email… got me a bit of an insight on commcare and it’s had
been a big help… but i hav a problem.
I tried to run commcare-hq in my laptop… followed the getting started
from 'http://wiki.github.com/dimagi/commcare-hq/getting-startedhttp://wiki.github.com/dimagi/commcare-hq/getting-started’
the runserver seems to run ok but couldnt view anything… and got this msg

Traceback (most recent call last):

File “/usr/lib/pymodules/python2.6/django/core/servers/basehttp.py”, line 279, in run
self.result = application(self.environ, self.start_response)

File “/usr/lib/pymodules/python2.6/django/core/servers/basehttp.py”, line 651, in call
return self.application(environ, start_response)

File “/usr/lib/pymodules/python2.6/django/core/handlers/wsgi.py”, line 230, in call

self.load_middleware()

File “/usr/lib/pymodules/python2.6/django/core/handlers/base.py”, line 37, in load_middleware
raise exceptions.ImproperlyConfigured, ‘%s isn’t a middleware module’ % middleware_path

ImproperlyConfigured: h isn’t a middleware module

my guess myb commcare is not compatible with the django am using…, hav
this happend to you??

Sorry for the spelling, need some coffee here :wink:

··· On Jan 28, 5:37 pm, Nir Yariv wrote: > Hi, I just encountered the same problem. It seems to be caused by > RapidSMS not parsing the [customdjango] directives properly. The value > is passed as string rather than an array containing a string, and the > for..in loop at webui/settings.py assuming this *is* an array - so for > 'hq.middleware.hq.HqMiddleware' it attempts to load module 'h', than > module 'q' etc... > > A quick fix was to add a type check cast the value into an array. I'm > attaching a diff below. Obviously that's not the ideal fix - the > problem is somewhere in RapidSMS Config class but I didn't dig too > deep into that.. > > # ==================== > # INJECT RAPIDSMS MIDDLEWARES IF PRESENT > # ==================== > - > + > +if type(RAPIDSMS_CONF["customdjango"]["middlewares"]) == str: > + RAPIDSMS_CONF["customdjango"]["middlewares"] = [RAPIDSMS_CONF > ["customdjango"]["middlewares"]] > + > +if type(RAPIDSMS_CONF["customdjango"]["authentications"]) == str: > + RAPIDSMS_CONF["customdjango"]["authentications"] = [RAPIDSMS_CONF > ["customdjango"]["authentications"]] > + > if "customdjango" in RAPIDSMS_CONF: > if "middlewares" in RAPIDSMS_CONF["customdjango"]: > MIDDLEWARE_CLASSES = MIDDLEWARE_CLASSES +\ > > On Jan 27, 10:52 am, Cory Zue wrote: > > > Hi Allen, > > > I'm cc-ing our google group in case any of the other developers have > > thoughts on this. In the future please send all questions to this group > > (and you should join so you can get updates about the code from other > > people!). > > > So it looks like somewhere in your Django settings you are referencing a > > middleware that doesn't exist. > > > The main settings file for commcare hq resides in the rapidsms submodule at > > lib/rapidsms/webui/settings.py. There you should see a list of middlewares > > like: > > > MIDDLEWARE_CLASSES = [ > > 'django.middleware.common.CommonMiddleware', > > 'django.contrib.sessions.middleware.SessionMiddleware', > > 'django.middleware.locale.LocaleMiddleware', > > 'django.contrib.auth.middleware.AuthenticationMiddleware', > > ] > > > We also allow you to add middlewares via your settings file (the local.ini > > file you should have copied from rapidsms.ini). This is done in the > > following section: > > > [customdjango] > > middlewares=hq.middleware.hq.HqMiddleware > > > Do both of these sections look the same as in your files? > > > thanks, > > Cory > > > On Tue, Jan 26, 2010 at 11:11 AM, Allen Machary wrote: > > > > hi... Cory ., > > > thanx for the email.. got me a bit of an insight on commcare and it's had > > > been a big help.. but i hav a problem. > > > I tried to run commcare-hq in my laptop... followed the getting started > > > from 'http://wiki.github.com/dimagi/commcare-hq/getting-started'.. > > > the runserver seems to run ok but couldnt view anything.. and got this msg > > > > Traceback (most recent call last): > > > > File "/usr/lib/pymodules/python2.6/django/core/servers/basehttp.py", line 279, in run > > > self.result = application(self.environ, self.start_response) > > > > File "/usr/lib/pymodules/python2.6/django/core/servers/basehttp.py", line 651, in __call__ > > > return self.application(environ, start_response) > > > > File "/usr/lib/pymodules/python2.6/django/core/handlers/wsgi.py", line 230, in __call__ > > > > self.load_middleware() > > > > File "/usr/lib/pymodules/python2.6/django/core/handlers/base.py", line 37, in load_middleware > > > raise exceptions.ImproperlyConfigured, '%s isn\'t a middleware module' % middleware_path > > > > ImproperlyConfigured: h isn't a middleware module > > > > my guess myb commcare is not compatible with the django am using.., hav > > > this happend to you??

Thanks Nir!

I've pushed your workaround to our fork of rapidsms
http://github.com/dimagi/rapidsms/commit/1a68786a79cc69c8817ae2185a27b51f4f49739c.
I don't know why it worked for us without this but not you guys, but
hopefully this at least resolves it.

Allen, let me know if you still have problems after pulling down the latest
version of rapidsms.

thanks,
Cory

··· On Thu, Jan 28, 2010 at 5:40 PM, Nir Yariv wrote:

Sorry for the spelling, need some coffee here :wink:

On Jan 28, 5:37 pm, Nir Yariv nirya...@gmail.com wrote:

Hi, I just encountered the same problem. It seems to be caused by
RapidSMS not parsing the [customdjango] directives properly. The value
is passed as string rather than an array containing a string, and the
for..in loop at webui/settings.py assuming this is an array - so for
'hq.middleware.hq.HqMiddleware' it attempts to load module 'h', than
module 'q' etc...

A quick fix was to add a type check cast the value into an array. I'm
attaching a diff below. Obviously that's not the ideal fix - the
problem is somewhere in RapidSMS Config class but I didn't dig too
deep into that..

====================

INJECT RAPIDSMS MIDDLEWARES IF PRESENT

====================

+if type(RAPIDSMS_CONF["customdjango"]["middlewares"]) == str:

  • RAPIDSMS_CONF["customdjango"]["middlewares"] = [RAPIDSMS_CONF
    ["customdjango"]["middlewares"]]

+if type(RAPIDSMS_CONF["customdjango"]["authentications"]) == str:

  • RAPIDSMS_CONF["customdjango"]["authentications"] = [RAPIDSMS_CONF
    ["customdjango"]["authentications"]]

if "customdjango" in RAPIDSMS_CONF:
if "middlewares" in RAPIDSMS_CONF["customdjango"]:
MIDDLEWARE_CLASSES = MIDDLEWARE_CLASSES +\

On Jan 27, 10:52 am, Cory Zue c...@dimagi.com wrote:

Hi Allen,

I'm cc-ing our google group in case any of the other developers have
thoughts on this. In the future please send all questions to this
group

(and you should join so you can get updates about the code from other
people!).

So it looks like somewhere in your Django settings you are referencing
a

middleware that doesn't exist.

The main settings file for commcare hq resides in the rapidsms
submodule at

lib/rapidsms/webui/settings.py. There you should see a list of
middlewares

like:

MIDDLEWARE_CLASSES = [
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.locale.LocaleMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
]

We also allow you to add middlewares via your settings file (the
local.ini

file you should have copied from rapidsms.ini). This is done in the
following section:

[customdjango]
middlewares=hq.middleware.hq.HqMiddleware

Do both of these sections look the same as in your files?

thanks,
Cory

On Tue, Jan 26, 2010 at 11:11 AM, Allen Machary < allen.mach...@gmail.com>wrote:

hi... Cory .,
thanx for the email.. got me a bit of an insight on commcare and it's
had

been a big help.. but i hav a problem.
I tried to run commcare-hq in my laptop... followed the getting
started

from 'http://wiki.github.com/dimagi/commcare-hq/getting-started'<
http://wiki.github.com/dimagi/commcare-hq/getting-started'>..

the runserver seems to run ok but couldnt view anything.. and got
this msg

Traceback (most recent call last):

File
"/usr/lib/pymodules/python2.6/django/core/servers/basehttp.py", line 279, in
run

self.result = application(self.environ, self.start_response)

File
"/usr/lib/pymodules/python2.6/django/core/servers/basehttp.py", line 651, in
call

return self.application(environ, start_response)

File "/usr/lib/pymodules/python2.6/django/core/handlers/wsgi.py",
line 230, in call

self.load_middleware()

File "/usr/lib/pymodules/python2.6/django/core/handlers/base.py",
line 37, in load_middleware

raise exceptions.ImproperlyConfigured, '%s isn\'t a middleware

module' % middleware_path

ImproperlyConfigured: h isn't a middleware module

my guess myb commcare is not compatible with the django am using..,
hav

this happend to you??