Unable to use contacts module
mirtouf opened this issue · 8 comments
Hi,
setting up the database tables and installing the contacts application for modoboa went fine but an error rises when modifying the setting.py file with
from modoboa_contacts import settings as modoboa_contacts_settings modoboa_contacts_settings.apply(globals())
Here is the output log:
SyntaxError: invalid syntax
Wed Nov 8 15:40:59 2017 - unable to load app 0 (mountpoint='mail.domain.tld|') (callable not found or import error)
Wed Nov 8 15:40:59 2017 - --- no python application found, check your startup logs for errors ---
mail.domin.tld [pid: 22513|app: -1|req: -1/5] 165.225.76.124 () {52 vars in 990 bytes} [Wed Nov 8 15:40:59 2017] GET / => generated 21 bytes in 2 msecs (HTTP/2.0 500) 2 headers in 83 bytes (0 switches on core 0)
Traceback (most recent call last):
File "./instance/wsgi.py", line 16, in <module>
application = get_wsgi_application()
File "/home/modoboa/env/local/lib/python2.7/site-packages/django/core/wsgi.py", line 13, in get_wsgi_application
django.setup(set_prefix=False)
File "/home/modoboa/env/local/lib/python2.7/site-packages/django/__init__.py", line 22, in setup
configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)
File "/home/modoboa/env/local/lib/python2.7/site-packages/django/conf/__init__.py", line 53, in __getattr__
self._setup(name)
File "/home/modoboa/env/local/lib/python2.7/site-packages/django/conf/__init__.py", line 41, in _setup
self._wrapped = Settings(settings_module)
File "/home/modoboa/env/local/lib/python2.7/site-packages/django/conf/__init__.py", line 97, in __init__
mod = importlib.import_module(self.SETTINGS_MODULE)
File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
File "./instance/settings.py", line 14
from modoboa_contacts import settings as modoboa_contacts_settings modoboa_contacts_settings.apply(globals())
Of course removing from modoboa_contacts import settings as modoboa_contacts_settings modoboa_contacts_settings.apply(globals()) make modobo working except contact application.
The import settings were added in top of the file as indicated (which seems very logic for python).
I am running modoboa 1.9.1 and modoboa-contacts 0.4.0, am I missing a dependency ?
Looks like you forgot a newline character. You config file should look like this:
from modoboa_contacts import settings as modoboa_contacts_settings
modoboa_contacts_settings.apply(globals())
First point the README shall be updated.
Second point, I still have an error but this is quite strange to me:
Wed Nov 8 16:03:02 2017 - unable to load app 0 (mountpoint='mail.mirtouf.fr|') (callable not found or import error)
Wed Nov 8 16:03:02 2017 - --- no python application found, check your startup logs for errors ---
mail.mirtouf.fr [pid: 29315|app: -1|req: -1/7] 165.225.76.124 () {46 vars in 700 bytes} [Wed Nov 8 16:03:02 2017] GET /robots.txt => generated 21 bytes in 4 msecs (HTTP/2.0 500) 2 headers in 83 bytes (0 switches on core 0)
Traceback (most recent call last):
File "./instance/wsgi.py", line 16, in <module>
application = get_wsgi_application()
File "/home/modoboa/env/local/lib/python2.7/site-packages/django/core/wsgi.py", line 13, in get_wsgi_application
django.setup(set_prefix=False)
File "/home/modoboa/env/local/lib/python2.7/site-packages/django/__init__.py", line 22, in setup
configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)
File "/home/modoboa/env/local/lib/python2.7/site-packages/django/conf/__init__.py", line 53, in __getattr__
self._setup(name)
File "/home/modoboa/env/local/lib/python2.7/site-packages/django/conf/__init__.py", line 41, in _setup
self._wrapped = Settings(settings_module)
File "/home/modoboa/env/local/lib/python2.7/site-packages/django/conf/__init__.py", line 97, in __init__
mod = importlib.import_module(self.SETTINGS_MODULE)
File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
File "./instance/settings.py", line 15, in <module>
modoboa_contacts_settings.apply(globals())
File "/home/modoboa/env/local/lib/python2.7/site-packages/modoboa_contacts/settings.py", line 17, in apply
DEBUG = settings['DEBUG']
KeyError: 'DEBUG'
The lines you added are at the end of your instance/settings.py file, right ?
I do not understand the answer, I added
from modoboa_contacts import settings as modoboa_contacts_settings modoboa_contacts_settings.apply(globals())
at the top of the file
At the end, there is an error 500 when trying to access the web interface.
Those lines must be placed at the end of the file. Set DEBUG to True to see what causes the 500 error.
OK, it is needed to modify the README from:
Add the following at the begining of the file:
from modoboa_contacts import settings as modoboa_contacts_settings modoboa_contacts_settings.apply(globals())
To
Add the following at the end of the file:
from modoboa_contacts import settings as modoboa_contacts_settings
modoboa_contacts_settings.apply(globals())
I see on my screen a space not a newline character.
Now, I have errors with webpack, I have to figure out:
Request Method: | GET
-- | --
https://mail.mirtouf.fr/contacts/
1.10.8
IOError
Error reading /home/modoboa/env/local/lib/python2.7/site-packages/modoboa_contacts/../frontend/webpack-stats.json. Are you sure webpack has generated the file and the path is correct?
/home/modoboa/env/local/lib/python2.7/site-packages/webpack_loader/loader.py in _load_assets, line 31
/usr/bin/uwsgi-core
2.7.13
['.', '', '/home/modoboa/env/lib/python2.7', '/home/modoboa/env/lib/python2.7/plat-x86_64-linux-gnu', '/home/modoboa/env/lib/python2.7/lib-tk', '/home/modoboa/env/lib/python2.7/lib-old', '/home/modoboa/env/lib/python2.7/lib-dynload', '/usr/lib/python2.7', '/usr/lib/python2.7/plat-x86_64-linux-gnu', '/usr/lib/python2.7/lib-tk', '/home/modoboa/env/local/lib/python2.7/site-packages', '/home/modoboa/env/lib/python2.7/site-packages']
Wed, 8 Nov 2017 15:31:32 +0000
Ah yes... When DEBUG is set to True, you need to run webpack server in dev mode (as explained in the README file).
Do you still have a 500 issue if you set DEBUG to False?
We are all done, I close this issue.