Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/305.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/oop/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python web.py中的继承?_Python_Oop_Wsgi_Web.py_Python 2.5 - Fatal编程技术网

Python web.py中的继承?

Python web.py中的继承?,python,oop,wsgi,web.py,python-2.5,Python,Oop,Wsgi,Web.py,Python 2.5,我目前正在开发wep.py应用程序。这是我的web应用程序,它与web.py和wsgi绑定在一起 root/main.py import web import sys import imp import os sys.path.append(os.path.dirname(__file__)) #from module import module from exam import exam urls = ( '/exam', 'exam' ) application = web.a

我目前正在开发wep.py应用程序。这是我的web应用程序,它与web.py和wsgi绑定在一起

root/main.py

import web
import sys
import imp
import os

sys.path.append(os.path.dirname(__file__))

#from module import module
from exam import exam
urls = (
    '/exam', 'exam'
)

application = web.application(urls, globals(), autoreload = True).wsgifunc()
我的应用程序在根目录的module.py中有一个名为module的抽象类,其目的是由模块继承

root/module.py

class module:
    def fetchURL(self, url):
        # ...
        return content
名为exam的较低级别模块将继承该模块

root/exam/init.py

调用父方法时,web.py引发异常

WalkerError:“意外节点类型”,339

环境:Python 2.5

我怎样才能解决这个问题?谢谢

//编辑03 July 10:22 GMT+0

堆栈跟踪如下所示

 mod_wsgi (pid=1028): Exception occurred processing WSGI script 'D:/py/labs_library/index.py'.
 Traceback (most recent call last):
   File "D:\csvn\Python25\lib\site-packages\web\application.py", line 277, in wsgi
     result = self.handle_with_processors()
   File "D:\csvn\Python25\lib\site-packages\web\application.py", line 247, in handle_with_processors
     return process(self.processors)
   File "D:\csvn\Python25\lib\site-packages\web\application.py", line 244, in process
     raise self.internalerror()
   File "D:\csvn\Python25\lib\site-packages\web\application.py", line 467, in internalerror
     return debugerror.debugerror()
   File "D:\csvn\Python25\lib\site-packages\web\debugerror.py", line 305, in debugerror
     return web._InternalError(djangoerror())
   File "D:\csvn\Python25\lib\site-packages\web\debugerror.py", line 290, in djangoerror
     djangoerror_r = Template(djangoerror_t, filename=__file__, filter=websafe)
   File "D:\csvn\Python25\lib\site-packages\web\template.py", line 845, in __init__
     code = self.compile_template(text, filename)
   File "D:\csvn\Python25\lib\site-packages\web\template.py", line 924, in compile_template
     ast = compiler.parse(code)
   File "D:\csvn\Python25\lib\compiler\transformer.py", line 51, in parse
     return Transformer().parsesuite(buf)
   File "D:\csvn\Python25\lib\compiler\transformer.py", line 128, in parsesuite
     return self.transform(parser.suite(text))
   File "D:\csvn\Python25\lib\compiler\transformer.py", line 124, in transform
     return self.compile_node(tree)
   File "D:\csvn\Python25\lib\compiler\transformer.py", line 167, in compile_node
     raise WalkerError, ('unexpected node type', n)
 WalkerError: ('unexpected node type', 339)

如果可能的话,我想关闭模板功能,因为我只将python用于移动应用程序的JSON输出。

如果您创建python模块,您应该在层次结构的顶部添加_init__;.py:

dvedit/
  __init__.py
  clipview.py
  filters/
    __init__.py
这意味着在每个目录中,将通过导入从。。。进口应该有_uinit__u.py文件


更多可用信息:

该错误似乎来自。也许你的模板有问题?其中引发异常的确切位置是,更完整的stacktrace将非常有用。@mata在调用父函数时引发异常,父函数在其他python脚本中定义。我还发布了堆栈跟踪,我已经为每个包创建了一个_uinit__u;.py。问题仍然存在。更多信息:在uuu init_uuuu.py中,我导入了smtplib import smtplib,这也会引发WalkerError:“意外节点类型”,339。堆栈跟踪与我的问题完全相同。您能提供您的系统路径吗?['C:\\Windows\\system32\\python27.zip','D:\\csvn\\Python25\\dll','D:\\csvn\\Python25\\lib','D:\\csvn\\Python25\\lib\\plat win','D:\\csvn\\Python25\\lib-tk','C:\\Program Files\\Apache Software Foundation\\Apache2.2\\bin','D:\\csvn\\Python25''D:\\csvn\\Python25\\lib site packages','D:\\csvn\\Python25\\lib site packages\\win32:\\csvn\\Python25\\lib\\site-packages\\win32\\lib',D:\\csvn\\Python25\\lib\\site-packages\\Pythonwin',D:/py/labs\u-library',D:/py/labs\u-library\\search']这是我的sys.path。非常感谢您今天的到来。尝试一下:Federico Frenguelli的回答:
dvedit/
  __init__.py
  clipview.py
  filters/
    __init__.py