F
F
fogersp2014-11-07 16:04:12
Python
fogersp, 2014-11-07 16:04:12

Python Bottle: why aren't changes in code being applied?

Good day! I'm starting to learn Python and the Bottle
web framework . Since I am switching from PHP to Python, after PHP everything is somehow difficult to understand. I am using mod_wsgi apache. The virtual host config is:

<VirtualHost *:80>
        ServerName bottle
        DocumentRoot /var/www/bottle/
        ErrorLog /var/www/bottle/error.log
        Customlog /var/www/bottle/access.log combined
        WSGIDaemonProcess hello user=www-data group=www-data processes=1 threads=5
        WSGIScriptAlias / /var/www/bottle/adapter.wsgi
        WSGIProcessGroup hello
        WSGIApplicationGroup %{GLOBAL}
        WSGIScriptReloading On
<Directory /var/www/bottle/>
        Options FollowSymLinks ExecCGI
        AddHandler wsgi-script .wsgi
        Order allow,deny
        AllowOverride All
        Allow from all
</Directory>
</VirtualHost>

I can not understand one thing: why when I change something in the code, the changes are not applied in the browser output or you add a route, but a 404 error is returned. Everything is solved by service apache2 reload. At first I thought maybe the browser cache - but no. It seems that I found WSGIScriptReloading On for the config - it is written that it should just solve this, but for some reason it does not help. It is not clear yet that I can change return "ABC" to return "DEF" in the function and the changes are visible in the browser, and for example, if you delete or add a new function, only Apache reload helps. Googled - I didn’t find anything like that, so I, as a beginner, don’t understand something and I’m doing it wrong.
adapter.wsgi:
import sys, os, bottle
sys.path.append(os.path.dirname(os.path.abspath(__file__)))
os.chdir(os.path.dirname(os.path.abspath(__file__)))
import hello
application = bottle.default_app()

hello.py
from bottle import Bottle, route, run, template, request, get, post
app = Bottle()
Route('/test')
def test():
    return "Test!"

Route('/hello/<name>')
def greet(name='user'):
    return template('Hello <b>{{name}}</b>, how are you?', name=name)

Help advice! I don’t want to get involved with more loaded Python frameworks for the time being - I liked Bottle because it’s easier to learn in one file and for a beginner. But so far development has stalled

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Rrooom, 2014-11-07
@fogersp

Have you ever run php under php-fpm? There also.
mod_wsgi is the essence of fastcgi and the changes will take effect only after the server is restarted.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question