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 用hfss做微带贴片阵列天线的时候分析设置有问题
  • ¥50 我撰写的python爬虫爬不了 要爬的网址有反爬机制
  • ¥15 Centos / PETSc / PETGEM
  • ¥15 centos7.9 IPv6端口telnet和端口监控问题
  • ¥120 计算机网络的新校区组网设计
  • ¥20 完全没有学习过GAN,看了CSDN的一篇文章,里面有代码但是完全不知道如何操作
  • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
  • ¥20 海浪数据 南海地区海况数据,波浪数据
  • ¥20 软件测试决策法疑问求解答
  • ¥15 win11 23H2删除推荐的项目,支持注册表等