Thank you very much Graham for the detailed explanation!

 

Sent from Mail for Windows 10

 

From: Graham Dumpleton
Sent: Σάββατο, 7 Μαρτίου 2020 10:56 μμ
To: [email protected]
Subject: Re: [modwsgi] Error accessing a route endpoint with same name in 2 processes

 

If you add debug statements to index(), what is the value of:

 

    request.environ.get('SCRIPT_NAME')

 

for the request?

 

Also add an import to the top of the script for the module 'mod_wsgi', and print the value of:

 

    mod_wsgi.process_group()

 

for the request.

 

Finally, look at the source code for the HTML coming back to your browser. What is the complete filled out form as seen by the browser.

 

What you should see for SCRIPT_NAME for original test.py is:

 

    /test

 

For the process group you should see:

 

    test

 

and in the form, the action should be:

 

    /test/mailform

 

When you hardwire action to '/mailform', because it lacks the '/test' prefix which is the mount point for the application, it will send to the www application mounted at '/' instead as it will not have the '/test' prefix.

 

So because you mounted application at a sub URL path, it is important that you use app.get_url() when generating all URLs so that the framework can add the mount point URL specified by SCRIPT_NAME to the start of all URLs.

 

Anyway, hope that helps as I wasn't 100% clear with what you were describing as the problem.

 

BTW, you really should avoid using WSGIScriptAliasMatch. There is usually never a need to and it can be tricky to use when trying to actually match a pattern as you need to give a hint as to the mount point to pass to the application. In this case you could have just used:

 

WSGIDaemonProcess test user=nikos group=nikos home=/home/nikos/wsgi

WSGIScriptAlias /test /home/nikos/wsgi/test.py process-group=test application-group=%{GLOBAL}
WSGIDaemonProcess www user=nikos group=nikos home=/home/nikos/wsgi

WSGIScriptAlias / /home/nikos/wsgi/www.py process-group=www application-group=%{GLOBAL}

 

There was no need to use WSGIScriptAliasMatch.

 

FWIW, you can see rules about URL reconstruction when needing to supply a URL in a response at:

 

 

This is in part what the app.get_url() function is doing.

 

Graham



On 8 Mar 2020, at 12:52 am, Νίκος Βέργος <[email protected]> wrote:

 

Therere 2 different scripts each running on its own process:

www.py is what is running on http://superhost.gr

and test.py is what is running on http://superhost.gr/test

Here is what it contains.



from bottle import Bottle, route, run, debug
application = Bottle()

app = application

debug(True)

@app.route('/mailform', method=['POST'])

def mailform():

    return 'Hello from mailform'


@app.route('/')

def index():

    return '''\

    <form method="post" action=""

    <input value="Mail" type="submit" /> </form>'''.format( app.get_url( '/mailform' ) )

 

I somehow beleive that the following apache conf directives somehow create problem.



WSGIDaemonProcess test user=nikos group=nikos home=/home/nikos/wsgiWSGIScriptAlias /test /home/nikos/wsgi/test.py process-group=test application-group=%{GLOBAL}
WSGIDaemonProcess www user=nikos group=nikos home=/home/nikos/wsgiWSGIScriptAliasMatch / /home/nikos/wsgi/www.py process-group=www application-group=%{GLOBAL}



The only way i can run this is the aforementioned.

IF instead i try to access the endpoint like the following:

 

@app.route('/')

    def index(): return '''\

    <form method="post" action="">

    <input value="Mail" type="submit" /> </form>'''

 

i receive:

Sorry, the requested URL 'http://superhost.gr/mailform' caused an error:
Internal Server ErrorException:

TypeError("argument of type 'NoneType' is not iterable",)Traceback:Traceback (most recent call last): File "/home/nikos/wsgi/bottle.py", line 996, in _handle out = route.call(**args) File "/home/nikos/wsgi/bottle.py", line 2007, in wrapper rv = callback(*a, **ka) File "/home/nikos/wsgi/www.py", line 189, in mailform if provider in FROM:TypeError: argument of type 'NoneType' is not iterable



I somehow beleive that the following apache conf directives somehow create problem.

You will see if you create a route endpoint called '/mailform' within '/' which is an alias of 'www.py' and you also have '/mailform' in 'superhost.gr/test' when the latter tries to post data to '/mailform' instead of sending them to 'superhost.gr/test/' it sends them to '/' which is 'superhost.gr'

 

--
You received this message because you are subscribed to the Google Groups "modwsgi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/modwsgi/706267e7-b7b4-4991-b635-6d9f3e1ba52a%40googlegroups.com.

 

--
You received this message because you are subscribed to the Google Groups "modwsgi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/modwsgi/DFBEFFB7-23BB-4DB5-A16B-DAA9D9CAC95F%40gmail.com.

 

--
You received this message because you are subscribed to the Google Groups "modwsgi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/modwsgi/5e640f2c.1c69fb81.e77a4.e00d%40mx.google.com.

Reply via email to