{"id":1098,"date":"2010-05-17T11:30:00","date_gmt":"2010-05-17T03:30:00","guid":{"rendered":"\/?p=1098"},"modified":"2010-05-17T11:30:00","modified_gmt":"2010-05-17T11:30:00","slug":"1098","status":"publish","type":"post","link":"https:\/\/blog.vimge.com\/archives\/other\/1098.html","title":{"rendered":"\u4e3a Python Server Pages \u548c Oracle \u6784\u5efa\u5feb\u901f Web \u5f00\u53d1\u73af\u5883"},"content":{"rendered":"

       \u901a\u8fc7\u53ef\u9760\u7684 Oracle \u6570\u636e\u5e93 10g<\/em>\u3001\u53ef\u4f38\u7f29\u7684 Apache Web \u670d\u52a1\u5668\u4ee5\u53ca\u76f4\u89c2\u7684\u3001\u9762\u5411\u5bf9\u8c61\u7684 Python \u7f16\u7a0b\u8bed\u8a00\u5b66\u4e60\u9ad8\u7ea7 Web \u7f16\u7a0b\u3002<\/h4>\n

       \u5404\u79cd\u5728 Web \u670d\u52a1\u5668\u548c\u6570\u636e\u5e93\u4e4b\u95f4\u5145\u5f53\u4e2d\u95f4\u5c42\u7684\u670d\u52a1\u5668\u7aef\u6280\u672f\u4f7f\u5f53\u4eca\u7684\u5f00\u53d1\u4eba\u5458\u83b7\u76ca\u532a\u6d45\uff0c\u8fd9\u4e9b\u6280\u672f\u5305\u62ec JavaServer Pages (JSP)\u3001Active Server Pages (ASP)\u3001PHP \u4ee5\u53ca PL\/SQL Server Pages\uff08\u5982\u679c\u60a8\u662f\u4e00\u4f4d Oracle \u5f00\u53d1\u4eba\u5458\uff09\u3002                                                                           \u6b66\u6c49\u767e\u5ea6\u63a8\u5e7f<\/font><\/strong><\/a><\/p>\n

      \u6211\u5728 2003 \u5e74\u9996\u6b21\u63a5\u89e6 Python \u7f16\u7a0b\u8bed\u8a00\uff0c\u5e76\u4ece\u90a3\u65f6\u8d77\u5f00\u59cb\u6c89\u8ff7\u4e8e\u8fd9\u79cd\u8bed\u8a00\u7684\u72ec\u7279\u9b45\u529b\u53ca\u5176\u7b80\u4fbf\u7684\u4f7f\u7528\u3002\u5b83\u662f\u4e00\u79cd\u9ad8\u7ea7\u8bed\u8a00\uff0c\u51e0\u4e4e\u7c7b\u4f3c\u4e8e\u4ee5\u7eaf\u82f1\u6587\u7f16\u5199\uff0c\u5c31\u597d\u50cf\u7f16\u7a0b\u4eba\u5458\u5bf9\u4e8e\u4f2a\u4ee3\u7801\u7684\u8ba4\u8bc6\u3002Python \u7684\u52a8\u6001\u672c\u8d28\u4f7f\u60a8\u80fd\u591f\u7f16\u5199\u6700\u7b80\u660e\u7684\u4ee3\u7801\u6765\u5b8c\u6210\u751a\u81f3\u6700\u590d\u6742\u7684\u4efb\u52a1\u3002<\/p>\n

      \u5728\u8fd9\u7bc7\u6587\u7ae0\u4e2d\uff0c\u6211\u5c06\u7b80\u8981\u4ecb\u7ecd\u4e00\u79cd\u521b\u5efa\u5b8c\u6574\u7684 Python Server Pages\/Oracle \u6570\u636e\u5e93 10g<\/em> \u5feb\u901f Web \u5f00\u53d1\u73af\u5883\u7684\u7b80\u5355\u65b9\u6cd5\u3002\u672c\u6587\u5047\u8bbe\u60a8\u6ca1\u6709\u5728 Windows \u6216 Linux \u7cfb\u7edf\u4e0a\u5b89\u88c5\u4efb\u4f55\u7ec4\u4ef6\u3002\uff08\u5982\u679c\u5df2\u5b89\u88c5\uff0c\u5219\u53ef\u4ee5\u76f8\u5e94\u5730\u8df3\u8fc7\u67d0\u4e9b\u6b65\u9aa4\u3002\uff09\u6240\u6709\u63d0\u5230\u7684\u7ec4\u4ef6\u90fd\u53ef\u514d\u8d39\u4e0b\u8f7d\uff0c\u5e76\u4e14\u4e0d\u9700\u8981\u4efb\u4f55\u8bb8\u53ef\u8d39\u7528\u3002<\/p>\n

Python \u548c Python Server Pages \u7684\u80cc\u666f<\/h3>\n

      Python \u63d0\u4f9b\u4e86\u5f3a\u5927\u7684\u81ea\u6211\u68c0\u6d4b\u529f\u80fd\u3001\u53ef\u52a8\u6001\u952e\u5165\u3001\u5b8c\u5168\u9762\u5411\u5bf9\u8c61\uff0c\u5e76\u5177\u6709\u53ef\u6269\u5c55\u6027\u4ee5\u53ca\u5e73\u53f0\u72ec\u7acb\u6027\uff08Windows\u3001Linux\u3001Solaris\u3001Mac OS\u3001Nokia \/ S60\u3001Pocket PC \u7b49\u7b49\uff09\u3002\u5b83\u4f7f\u60a8\u80fd\u591f\u83b7\u5f97\u9ad8\u751f\u4ea7\u7387\u5e76\u4ee5\u7ed3\u679c\u4e3a\u5bfc\u5411\uff0c\u91cd\u5728\u89e3\u51b3\u95ee\u9898\u800c\u975e\u5e94\u5bf9\u8bed\u8a00\u56fa\u6709\u7279\u6027\u3002Python \u7684\u53ef\u8bfb\u6027\u5f88\u5f3a\uff0c\u975e\u5e38\u6613\u4e8e\u7ef4\u62a4\uff08\u901a\u8fc7\u5bf9\u4ee3\u7801\u6837\u5f0f\u63d0\u51fa\u7279\u5b9a\u8981\u6c42\uff09\u3002\u6211\u6709\u8bb8\u591a\u5b9e\u9645\u4e0a\u53ef\u4ee5\u6267\u884c\u590d\u6742\u4efb\u52a1\u7684 Python \u5355\u884c\u7a0b\u5e8f\uff08\u6709\u65f6\u662f\u53cc\u884c\u7a0b\u5e8f\uff0c\u5982\u679c\u5305\u542b\u5bfc\u5165\u8bed\u53e5\uff09\uff0c\u5b83\u4eec\u8fdc\u6bd4“hello-world”\u90a3\u6837\u7684\u7a0b\u5e8f\u529f\u80fd\u5f3a\u5927\u3002<\/p>\n

      Python \u6700\u5927\u7684\u4f18\u52bf\u4e4b\u4e00\u662f\u5176\u5e7f\u6cdb\u7684\u6807\u51c6\u5e93\uff0c\u5176\u4e2d\u63d0\u4f9b\u4e86\u53ef\u7528\u4e8e\u5927\u591a\u6570\u7f16\u7a0b\u4efb\u52a1\u7684\u73b0\u6210\u6a21\u5757\u7ec4\uff08Python \u7f16\u7a0b\u4eba\u5458\u79f0\u5176\u4e3a“\u5e26\u7535\u6c60\u7684\u7b56\u7565”\uff09\uff0c\u5305\u62ec\u6587\u4ef6 I\/O\u3001\u7cfb\u7edf\u4ea4\u4e92\u3001\u8054\u7f51\u3001\u6570\u636e\u5206\u6790\u548c\u64cd\u4f5c\u3001\u7ebf\u7a0b\u3001\u76d1\u6d4b\u3001\u5355\u5143\u6d4b\u8bd5\u3001\u81ea\u6211\u68c0\u6d4b\u3001XML \u5904\u7406\u7b49\u7b49\u3002<\/p>\n

      \u60a8\u5c06\u4f1a\u7740\u8ff7\u4e8e\u5229\u7528 Python \u83b7\u5f97\u7684\u5f00\u53d1\u901f\u5ea6 — \u6700\u7ec8\u53ef\u4ee5\u8ba9\u8ba1\u7b97\u673a\u7406\u89e3\u800c\u4e0d\u662f\u8bef\u89e3\u60a8\u7684\u610f\u56fe\u3002\u6b64\u5916\uff0c\u5229\u7528\u5185\u7f6e\u7684\u6587\u6863\u5b57\u7b26\u4e32 (docstring) — \u5373\u5185\u5d4c\u7684\u5e2e\u52a9\u5b57\u7b26\u4e32\uff0c\u5176\u4ed6\u7f16\u7a0b\u4eba\u5458\u53ef\u4ee5\u5feb\u901f\u7406\u89e3\u60a8\u7684\u7c7b\u6216\u51fd\u6570\u7684\u7cbe\u9ad3\u3002\uff08\u4ece\u6e90\u4ee3\u7801\u521b\u5efa\u6587\u6863\u8f7b\u800c\u6613\u4e3e\u3002\uff09\u6b63\u662f\u7531\u4e8e\u8fd9\u4e9b\u539f\u56e0\uff0cGoogle \u548c NASA \u4f7f\u7528\u4e86\u5927\u91cf\u7684 Python\uff0c\u800c Microsoft \u6b63\u5728 .NET \u5e73\u53f0\u4e0a\u5f00\u53d1\u81ea\u5df1\u7684 Python \u7248\u672c\uff0c\u79f0\u4e3a IronPython\u3002<\/p>\n

      Python Server Pages (PSP) \u4e4b\u4e8e Python \u6b63\u5982 Java Server Pages \u4e4b\u4e8e Java\u3002\u8f83\u4e4b\u4ee5\u5e38\u89c4 CGI \u5904\u7406\u7684\u9875\u9762\uff0c\u5229\u7528 PSP \u5448\u73b0\u7684\u9875\u9762\u7684\u6267\u884c\u6548\u679c\u8981\u597d 50 \u500d<\/a>\u3002Mod_python \u5305\u542b\u4e86\u8bb8\u591a\u4e13\u95e8\u7684\u6a21\u5757\uff0c\u4f7f\u5f97 Web \u5f00\u53d1\u66f4\u7b80\u5355\u3002<\/p>\n

\u89e3\u51b3\u65b9\u6848\u7ec4\u4ef6<\/h2>\n

      \u5b8c\u6574\u7684 Web \u5f00\u53d1\u73af\u5883\u81f3\u5c11\u5fc5\u987b\u5305\u542b\u4e09\u4e2a\u57fa\u672c\u7ec4\u4ef6\uff1aWeb \u670d\u52a1\u5668\u3001\u6570\u636e\u5e93\u4ee5\u53ca\u670d\u52a1\u5668\u7aef\u540e\u7aef\u6280\u672f\u3002\u6b64\u5916\u8fd8\u6709\u4e00\u4e9b\u529f\u80fd\u8981\u6c42\uff0c\u4f8b\u5982\u53ef\u9760\u6027\u3001\u53ef\u4f38\u7f29\u6027\u4ee5\u53ca\u4e92\u64cd\u4f5c\u6027\u3002\u4e3a\u4e86\u6ee1\u8db3\u4e0a\u8ff0\u6761\u4ef6\uff0c\u6211\u9009\u62e9\u4f7f\u7528 Apache HTTP Server 2.0\u3001Oracle \u6570\u636e\u5e93 10g<\/em> \u5feb\u6377\u7248 (XE) \u4ee5\u53ca Python 2.4\uff08\u5e26\u6709 mod_python \u548c cx_Oracle \u6a21\u5757\uff09\u3002\uff08\u8bf7\u9605\u8bfb\u5e76\u627e\u51fa\u9009\u62e9\u8fd9\u4e09\u9879\u7684\u539f\u56e0\u3002\uff09<\/p>\n

      \u4e0d\u4f46 Linux \u7528\u6237\u4ecd\u7136\u65e0\u9700\u952e\u5165\u592a\u591a\u5185\u5bb9\uff0c\u5c31\u662f Windows \u7528\u6237\u4e5f\u5fc5\u5b9a\u4eab\u53d7\u6240\u6709\u8fd9\u4e9b\u7ec4\u4ef6\u7684\u7b80\u5355\u5b89\u88c5\u65b9\u5f0f\uff08\u53ea\u9700\u5355\u51fb\u3000Next\uff09\u3002\u6211\u5df2\u7ecf\u7b80\u5316\u4e86\u5b89\u88c5\u8fc7\u7a0b\uff0c\u4ee5\u5229\u7528\u53ef\u7528\u7684\u4e8c\u8fdb\u5236\u6587\u4ef6\u3002<\/p>\n

Oracle \u6570\u636e\u5e93 10g<\/em> \u5feb\u6377\u7248<\/h2>\n

      2006 \u5e74 2 \u6708\uff0cOracle \u63a8\u51fa\u4e86 Oracle \u6570\u636e\u5e93\u5feb\u6377\u7248\u7684\u751f\u4ea7\u7248\u3002\u5b83\u662f Oracle \u6570\u636e\u5e93 10g<\/em> \u7b2c 2 \u7248\u7684\u5c0f\u578b\u5165\u95e8\u7ea7\u7248\u672c\uff0c\u5176\u5f00\u53d1\u3001\u90e8\u7f72\u4ee5\u53ca\u5206\u53d1\u5b8c\u5168\u514d\u8d39\u3002<\/p>\n

      Oracle \u6570\u636e\u5e93\u5feb\u6377\u7248\u9002\u7528\u4e8e Windows \u548c Linux \u64cd\u4f5c\u7cfb\u7edf\uff0c\u662f PHP\u3001Java \u6216 .NET \u5f00\u53d1\u4eba\u5458\u7684\u9996\u9009\u3002\u6b64\u5916\uff0c\u5229\u7528\u5927\u91cf\u53ef\u7528\u7684\u7b2c\u4e09\u65b9\u6a21\u5757\u548c\u9a71\u52a8\u7a0b\u5e8f\uff0c\u53ef\u4ee5\u901a\u8fc7\u5404\u79cd\u4e0d\u540c\u7684\u7f16\u7a0b\u8bed\u8a00\uff08\u5305\u62ec Python\uff09\u8bbf\u95ee\u8be5\u6570\u636e\u5e93\u3002                                                        \u6b66\u6c49\u767e\u5ea6<\/font><\/strong><\/a><\/font><\/strong><\/p>\n

       Oracle \u6570\u636e\u5e93\u5feb\u6377\u7248\u5177\u6709\u897f\u6b27\u4e0e\u901a\u7528\u4e24\u79cd\u7248\u672c\u3002\u524d\u8005\u53ea\u652f\u6301 LATIN1 \u5b57\u7b26\uff0c\u800c\u540e\u8005\u7684\u9ed8\u8ba4\u5b57\u7b26\u96c6\u4e3a AL32UTF8\u3002\u901a\u7528\u7248\u672c\u8fd8\u5305\u62ec\u7ffb\u8bd1\u4e3a\u5df4\u897f\u8461\u8404\u7259\u6587\u3001\u4e2d\u6587\uff08\u7b80\u4f53\u548c\u7e41\u4f53\uff09\u3001\u82f1\u6587\u3001\u6cd5\u6587\u3001\u5fb7\u6587\u3001\u610f\u5927\u5229\u6587\u3001\u65e5\u6587\u3001\u97e9\u6587\u4ee5\u53ca\u897f\u73ed\u7259\u6587\u7684\u7ba1\u7406\u754c\u9762\u3002\u6ca1\u6709\u4eba\u613f\u610f\u4ec5\u9650\u4e8e\u4f7f\u7528 LATIN1\uff0c\u56e0\u6b64\u6211\u5efa\u8bae\u5b89\u88c5\u5e76\u4f7f\u7528\u901a\u7528\u7248\u3002<\/p>\n

\u5b89\u88c5\u5e76\u8fd0\u884c Oracle \u6570\u636e\u5e93\u5feb\u6377\u7248<\/h3>\n

\u4e0b\u8f7d<\/a>\u9002\u7528\u4e8e Windows \u7684 OracleXEUniv.exe \u6216\u9002\u7528\u4e8e\u57fa\u4e8e RPM \u7684 Linux \u7248\u672c\u7684 oracle-xe-univ-10.2.0.1-1.0.i386.rpm\u3002\uff08Oracle \u6570\u636e\u5e93\u5feb\u6377\u7248\u4e5f\u9002\u7528\u4e8e Debian\uff0c\u4f46\u8fd9\u8d85\u51fa\u4e86\u672c\u6587\u6863\u7684\u8ba8\u8bba\u8303\u56f4\u3002\uff09<\/p>\n

\u5728 Windows \u5e73\u53f0\u4e0a\uff1a<\/strong><\/p>\n

    \n
  1. \u4f7f\u7528\u5177\u6709\u7ba1\u7406\u5458\u6743\u9650\u7684\u5e10\u6237\u767b\u5f55 Windows\u3002<\/li>\n
  2. \u5982\u679c\u7cfb\u7edf\u4e4b\u524d\u5df2\u8bbe\u7f6e\u4e86 ORACLE_HOME<\/font><\/tt> \u53d8\u91cf\uff0c\u8bf7\u5c06\u5176\u79fb\u9664\u3002<\/li>\n
  3. \u53cc\u51fb\u7b2c\u4e00\u6b65\u4e2d\u4e0b\u8f7d\u7684\u5b89\u88c5\u53ef\u6267\u884c\u6587\u4ef6\u3002
    \"\u56fe<\/li>\n
  4. \u5728 Oracle Database 10g<\/em> Express Edition – Install Wizard<\/strong> \u4e2d\uff0c\u5355\u51fb Next<\/strong>\u3002<\/li>\n
  5. \u5728 License Agreement<\/strong> \u7a97\u53e3\u4e2d\uff0c\u9009\u62e9 I accept<\/strong>\uff0c\u7136\u540e\u5355\u51fb Next<\/strong>\u3002
    \"\u56fe<\/li>\n
  6. \u5f53 Choose Installation Location<\/strong> \u7a97\u53e3\u5f39\u51fa\u540e\uff0c\u60a8\u53ef\u4ee5\u63a5\u53d7\u9ed8\u8ba4\u76ee\u5f55\uff0c\u4e5f\u53ef\u4ee5\u901a\u8fc7\u5355\u51fb Browse<\/strong> \u6309\u94ae\u9009\u62e9\u6240\u9700\u7684\u76ee\u6807\u4f4d\u7f6e\u3002\u5b8c\u6210\u8be5\u6b65\u9aa4\u540e\uff0c\u5355\u51fb Next<\/strong>\u3002<\/li>\n
  7. \u5982\u679c\u7cfb\u7edf\u63d0\u793a\u8f93\u5165\u7aef\u53e3\u53f7\uff0c\u60a8\u5e94\u5f53\u6307\u5b9a\u4e00\u4e2a\u3002Oracle \u6570\u636e\u5e93\u5feb\u6377\u7248\u7684\u9ed8\u8ba4\u7aef\u53e3\u53f7\u662f\n