wsgi

Django startup code with wsgi lazy loading

匆匆过客 提交于 2019-12-11 11:54:09
问题 I am running a Django application using Apache+mod_wsgi. When starting up Apache, it seems that the wsgi always lazyloads its app which means that no code is executed when Apache is started. Only when the first request comes in is the whole app loaded, initalized, etc and returned to the user. As I need to run some code without having to rely on the first request, I was wondering if this "lazy loading" can somehow be turned off or workedaround? I tried the WSGIImportScript VirtualHost

mod_wsgi forbidden error on CentOS 5.7

人走茶凉 提交于 2019-12-11 07:46:39
问题 I know that this question was asked millions of times, but i already spent many hours trying to configure Apache and mod_wsgi on CentOS 5.7, which it new to me. Never faced this kind of problem on Debian (Ubuntu). I've created wsgi.conf in /etc/httpd/conf.d/ directory, containting the following lines: LoadModule wsgi_module modules/mod_wsgi.so WSGIPythonHome /var/xxx/env /var/xxx/env contains virtual environment for the project. Then I've added the following lines into /etc/httpd/conf.d/ssl

WSGI process reload modules

橙三吉。 提交于 2019-12-11 06:39:15
问题 I'm trying to trigger a reload of my WSGI process when any file changes in the folder where it and all it's dependent modules are located. I've read http://code.google.com/p/modwsgi/wiki/ReloadingSourceCode and I thought I understood it, but this intermittent staleness makes me doubt myself. I'm running in daemon mode like this: DocumentRoot /usr/local/www/mysite.com/public_html WSGIScriptAlias /api /usr/local/www/mysite.com/server/server.py WSGIPassAuthorization On WSGIDaemonProcess mysite

Serving 2 django sites with the same code

拥有回忆 提交于 2019-12-11 06:37:31
问题 I'm serving a django site with apache and wsgi using an apache config as follow: Alias /media/ /var/www/media/ Alias /files/ /var/www/files/ WSGIDaemonProcess fc processes=5 threads=5 display-name=%{GLOBAL} WSGIProcessGroup fc WSGIScriptAlias / /home/path/to/django.wsgi The app is served in the root directory of the host. I'd like now to change this so I can serve it at http://host/app1 and another one, with a different django setting, at http://host/app2 How can I change the config to do

Django with apache and wsgi throws ImportError

一个人想着一个人 提交于 2019-12-11 05:56:50
问题 I'm trying to deploy my Django app to an Apache server with no luck. I succeeded with the WSGI sample application, and tried to host an empty Django project. While it works properly with the manage.py runserver, it throws the following error when using apache: [notice] Apache/2.2.22 (Debian) PHP/5.4.4-14+deb7u9 mod_python/3.3.1 Python/2.7.3 mod_wsgi/2.7 configured -- resuming normal operations [error] [client x.x.x.x] mod_wsgi (pid=8300): Exception occurred processing WSGI script '/usr/local

Django url template tags adding absolute filepath

邮差的信 提交于 2019-12-11 04:54:01
问题 I am having a problem where my {% url %} django template tag is adding the filepath to the web address in production. This is not replicated on my local development machine. With urls.py setup such that: url("^about_us/$", views.about_us, name="about_us"), In production, I am getting the link www.mysite.com/home/username/myapp/about_us instead of www.mysite.com/about_us I have looked at this similar issue and it does not help with my specific application: Django url tag adds filepath My

Mocking a method outside of a class

寵の児 提交于 2019-12-11 04:17:49
问题 I need to write a unit test for credential checking module looks something like below. I apologize I cannot copy the exact code.. but I tried my best to simplify as an example. I want to patch methodA so it returns False as a return value and test MyClass to see if it is throwing error. cred_check is the file name and MyClass is the class name. methodA is outside of MyClass and the return value checkedcredential is either True or False. def methodA(username, password): #credential check logic

Django Apache wsgi virtualenv import error

与世无争的帅哥 提交于 2019-12-11 03:24:10
问题 I'm trying to deploy Django (located in a virtualenv) on Apache using WSGI deploying. I'm following the default tutorial from https://docs.djangoproject.com/en/dev/howto/deployment/wsgi/modwsgi/ wsgi.py (the default one which Django generated, with the comments dropped): import os os.environ.setdefault("DJANGO_SETTINGS_MODULE", "server.settings") from django.core.wsgi import get_wsgi_application application = get_wsgi_application() apache2.conf (its the same httpd.conf just in Debian ).

django-mssql not working in Apache w/ mod-wsgi, but works fine in dev server

佐手、 提交于 2019-12-11 03:08:39
问题 I have a Django application using django-mssql to communicate w/ SQL Server. This works just fine in the dev server (runserver) but under Apache/mod-wsgi, I get a fail related to it trying to find a .dll which does exist: [Thu May 19 15:35:09 2011] [error] [client 127.0.0.1] File "C:\\Python27\\lib\\site-packages\\win32\\lib\\pywintypes.py", line 98, in __import_pywin32_system_module__ [Thu May 19 15:35:09 2011] [error] [client 127.0.0.1] raise ImportError("No system module '%s' (%s)" %

apache2 error log. Call to 'site.addsitedir()' failed for '(null)', stopping

霸气de小男生 提交于 2019-12-11 02:57:27
问题 I would like to connect Python and Apache 2 server in Ubuntu. So aws have to enter the following code ubuntu server. pip install Django sudo apt-get install appache2 sudo apt-get install libapache2-mod-wsgi-py3 Then I created the Python project and the app folder as Python venv. The code for Apache 2 000-default.conf looks like this: <virtualhost *:80> WSGIDaemonProcess bot python-path=/home/ubuntu/Django/bot:/home/ubuntu/Django/myvenv/lib/python3.5/site-packages ServerAdmin webmaster