Differences between revisions 2 and 3
Revision 2 as of 2005-07-16 07:05:47
Size: 3765
Editor: ZoomQuiet
Comment:
Revision 3 as of 2005-07-16 07:31:52
Size: 3809
Editor: ZoomQuiet
Comment: 支持包含
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:
## page was renamed from WukooPy/QuickInto

如何利用 WukooPy 进行Web 发布 ::-- ZoomQuiet [DateTime(2005-07-16T07:05:19Z)]

建立一个wukoo_helloworld包

所有应用项目均以python包方式发布,在这里建立python包的方法很多,不再详述。用于测试,比较偷赖的方法是:

1)在系统site-packages子目录下建立wukoo_helloworld子目录

2)在wukoo_helloworld下建立一个init.py

这样我们就建立了一个wukoo_helloworld包,下面如不特指,一切操作均在wukoo_helloworld子目录下进行

建立项目

建立发布内容

增加一个helloword.py文件,内容:

   1 def helloworld(wkp):
   2     return 'Hello World'

这样我们就做了一个函数发布的页面,页面内容为Hello World,wkp参数为api调用入口

制作页面发布接口

建立发布内容后,就要建立url调用逻辑,这种系统指定使用一个root函数,修改文件为

   1 def helloworld(wkp):
   2     return 'Hello World'
   3 
   4 def root():
   5     result=helloworld
   6     return result

制作项目发布接口

每个项目均应制作一个内容发布接口函数create_publisher,该函数调用不用的语法规则(使用不用的publisher),上页内容增加为:

   1 def helloworld(wkp):
   2     return 'Hello World'
   3 
   4 def root():
   5     result=helloworld
   6     return result
   7 
   8 from wukoopy.publish_wukoopy import Publisher ##使用publish_wukoopy发布
   9 def create_publisher():
  10     return Publisher(
  11         root
  12         )

wukoopy下内置quixote1,quixote2,wukoopy,karrigell四种发布方式,Publisher 参数为:

第一个参数:项目入口,每种publisher的入口形式均不一样,wukoopy为root函数

session_manager:为使用sessions,不加则不使用

config:配置文件

logger:log记录

**kwargs :其它配置

到此我们的项目基本做完了

选择不同方式发布

在wukoo.server下有不同的server发布方式

1)选择simple方式

(1)在命令行下执行

python \*\*\simple_server.py --factory wukoo_helloworld.helloworld.create_publisher

(2)使用python程序

建立一个run_simple.py文件,内容

   1 from wukoo_helloworld.helloworld import create_publisher
   2 from wukoopy.server.simple_server import run
   3 run(create_publisher)

运行后,访问http://localhost:8080/

2)选择cgi访问

建立一个run_cgi.cgi文件,并放在apache可以访问的地方

   1 from wukoo_helloworld.helloworld import create_publisher
   2 from wukoopy.server.cgi_server import run
   3 run(create_publisher)

3)选择fast cgi访问

建立一个run_cgi.fcgi文件,并放在apache可以访问的地方(apache配置不详述)

   1 from wukoo_helloworld.helloworld import create_publisher
   2 from wukoopy.server.fastcgi_server import run
   3 run(create_publisher)

4)选择xitami访问

建立一个run_xitami.py文件

   1 from wukoo_helloworld.helloworld import create_publisher
   2 from wukoopy.server.xitami_server import run
   3 run(create_publisher,'helloworld')

5)选择mod_python访问

配置apache.conf

<LocationMatch "^/helloworld(/|$)">
    SetHandler python-program
    PythonHandler wukoopy.server.mod_python_handler
    PythonOption quixote-publisher-factory wukoo_helloworld.helloworld.create_publisher
    PythonInterpreter wukoo_helloworld.helloworld
    PythonDebug On
</LocationMatch>

6)选择scgi方式

(略)

7)server下还用几种发布方式,参照上述进行。(有一些还是半成品,文件名中有todo)

暂时到这:)

WukooPyQuickInto (last edited 2009-12-25 07:15:25 by localhost)