Can we consider "mod_python" as the equivalent of "OBDC" for Database servers?

ساخت وبلاگ

Vote count: 0

In the database world, any DBMS has it's own API.

For the sake of having a lingua franca across database servers, OBDC (Open DataBase Connectivity) was invented.

I'm trying to understand WSGI and in Wikipedia I found this:

«The Web Server Gateway Interface (WSGI) is a specification for simple and universal interface between web servers and web applications or frameworks for the Python programming language.»

First question:

1) That saying, can we consider WSGI as the equivalent of ODBC for web servers?


Now the classic "Hello World" in mod_python:

from mod_python import apache
html = """
<html>
<body> Hello World !
</body>
</html>
"""
def handler(req): req.content_type = 'text/plain' req.write(html) return apache.OK


And now, with mod_wsgi:

#!/usr/bin/env python
from wsgiref.simple_server import make_server
html = """
<html>
<body> Hello World !
</body>
</html>
"""
def application(environ, start_response): status = '200 OK' response_headers = [ ('Content-Type', 'text/html'), ('Content-Length', str(len(html))) ] start_response(status, response_headers) return [html]
httpd = make_server('localhost', 8051, application)
httpd.serve_forever()
# Listening at http://localhost:8051


More questions

2) The function handler(req) in the mod_python code is a callback? If so, what is the code that calls this function?

3) Basically, mod_python is an embedded Python interpreter inside Apache. Does WSGI is also an embedded Python interpreter?

4) Giving the two last lines of code:

httpd = make_server('localhost', 8051, application)
httpd.serve_forever()

Can we say that we are creating our own web server and out it running forever? If we are creating our own server, why do we neeed Apache?

5) Since the first line in the mod_wsgi is:

#!/usr/bin/env python

Can we conclude that wsgi is a variation of CGI because the Python interpreter is launched out of the Apache process ?

Thank you

asked 36 secs ago

back soft...
ما را در سایت back soft دنبال می کنید

برچسب : نویسنده : استخدام کار backsoft بازدید : 229 تاريخ : سه شنبه 29 فروردين 1396 ساعت: 2:44