LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 1217|回复: 0

在mod_python中写的py文件怎么调用另一个文件中的函数或者类?

[复制链接]
发表于 2005-12-18 12:59:07 | 显示全部楼层 |阅读模式
实在没辙了,还是拜托大家把

在mod_python中写的py文件怎么调用另一个文件中的函数或者类?

比如我有a.py和b.py
a.py

  1. class Aa:
  2.     def __init__(self,string):
  3.         self.str=string
  4.     def getstr(self):
  5.         return "<html><body>%s</body></html>"%self.str

  6. def mm(string):
  7.     return "<html><body>%s</body></html>"%string
复制代码

b.py

  1. [Copy to clipboard]
  2. def test(req):
  3.     import os
  4.     import a
  5.     c=a.Aa("ok")
  6.     return c.getstr()
复制代码

但是调用的时候 http://192.168.28.150/psp/lesson/b/test
总是发生错误:


  1. Mod_python error: "PythonHandler mod_python.publisher"

  2. Traceback (most recent call last):

  3.   File "/usr/lib/python2.3/site-packages/mod_python/apache.py", line 299, in HandlerDispatch
  4.     result = object(req)

  5.   File "/usr/lib/python2.3/site-packages/mod_python/publisher.py", line 136, in handler
  6.     result = util.apply_fs_data(object, req.form, req=req)

  7.   File "/usr/lib/python2.3/site-packages/mod_python/util.py", line 361, in apply_fs_data
  8.     return object(**args)

  9.   File "/data/wwwftp/psp/lesson/b.py", line 7, in test
  10.     c=a.Aa("ok")

  11. AttributeError: 'module' object has no attribute 'Aa'
复制代码

可是在命令行上运行就没有问题
哪位能帮忙看一下到底哪里出了问题?
您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表