duan111112 2009-05-16 16:01
浏览 40
已采纳

mod_php vs mod_python

Why mod_python is oop but mod_php is not ?

Example :We go to www.example.com/dir1/dir2

if you use mod_python apache opens www/dir1.py and calls dir2 method but if you use php module apache opens www/dir1/dir2/index.php

  • 写回答

6条回答 默认 最新

  • dozoqn3347 2009-05-17 03:02
    关注

    Let's talk about mod_python vs. mod_php.

    Since the Python language is NOT specifically designed for serving web pages, mod_python must do some additional work.

    Since the PHP language IS specifically designed to serve web pages, mod_php simply starts a named PHP module.

    In the case of mod_python (different from mod_fastcgi or mod_wsgi), the designer of mod_python decided that the best way to invoke Python is to call a method of an object defined in a module. Hopefully, that method of that object will write the headers and web page content to stdout.

    In the case of mod_wsgi, the designer decided that the best way to invoke Python is to call a function (or callable object) in a module. Hopefully that function will use the supplied object to create header and return a list strings with the web page content.

    In the case of mod_php, they just invoke the module because PHP modules are designed to serve web pages. The program runs and the result of that run is a page of content; usually HTML.

    The reason mod_php works one way, mod_python works another and mod_wsgi works a third way is because they're different. Written by different people with different definitions of the way to produce a web page.

    The php page can be object-oriented. A mod_wsgi function may be a callable object or it may be a simplef unction. Those are design choices.

    The mod_python requirement for a class is a design choice made by the designer of mod_python.

    The reason "why" is never useful. The reason "why" is because someone decided to design it that way.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(5条)

报告相同问题?

悬赏问题

  • ¥15 用windows做服务的同志有吗
  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图