|
实在没辙了,还是拜托大家把
在mod_python中写的py文件怎么调用另一个文件中的函数或者类?
比如我有a.py和b.py
a.py
- class Aa:
- def __init__(self,string):
- self.str=string
- def getstr(self):
- return "<html><body>%s</body></html>"%self.str
- def mm(string):
- return "<html><body>%s</body></html>"%string
复制代码
b.py
- [Copy to clipboard]
- def test(req):
- import os
- import a
- c=a.Aa("ok")
- return c.getstr()
复制代码
但是调用的时候 http://192.168.28.150/psp/lesson/b/test
总是发生错误:
- Mod_python error: "PythonHandler mod_python.publisher"
- Traceback (most recent call last):
- File "/usr/lib/python2.3/site-packages/mod_python/apache.py", line 299, in HandlerDispatch
- result = object(req)
- File "/usr/lib/python2.3/site-packages/mod_python/publisher.py", line 136, in handler
- result = util.apply_fs_data(object, req.form, req=req)
- File "/usr/lib/python2.3/site-packages/mod_python/util.py", line 361, in apply_fs_data
- return object(**args)
- File "/data/wwwftp/psp/lesson/b.py", line 7, in test
- c=a.Aa("ok")
- AttributeError: 'module' object has no attribute 'Aa'
复制代码
可是在命令行上运行就没有问题
哪位能帮忙看一下到底哪里出了问题? |
|