2012-12-04 40 views
0

我只想说明,在Windows中,工作正常,但是当我尝试在我的VPS中部署此脚本时,它会失败。无法将映射添加到WebPy中的子应用程序

这是有点奇怪,因为如果我添加一个映射到主Web应用程序实例,它是“mainwebapp”它的工作原理,但每当我将它添加到任何子应用程序它显示为webpy“未找到”因为这个,我的头靠在墙上。

在Windows中,我有Wamp 2.2。在我的VPS我有CentOS 5,nginx uWsgi和相同的Python(2.7)&从我的Windows Webpy版本。

我几乎可以肯定这是nginx/uwsgi的问题,因为当我切换到我的Vps中的apache/mod_wsgi时,它也可以在我的Wamp本地服务器中工作。

到目前为止,这是我一直在测试的代码,这是一个非常简单的一个:

class subappcls: 
    def GET(self): 
      return "This will also be shown fine" 


sub_mappings = (
    "/subpath", subappcls 
) 


#subclass web app 
subwebapp = web.application(sub_mappings, globals()) 



#mapped clas 
class mapped_cls: 
def GET(self): 
    return "this mapped sub app will not be found" 


#Here I add mappings: 
subwebapp.add_mapping("/mapped_sub_path", mapped_cls 



class appcls: 
def GET(self): 
    return "main app" 



main_mappings = (
    "/subapp", subwebapp, 
    "/app", appcls 
) 

mainwebapp = web.application(main_mappings, fvars=globals()) 

class indexcls: 
def GET(self): 
    return "this will be shown just fine" 

mainwebapp.add_mapping("/another",indexcls) 


application = mainwebapp.wsgifunc() 

当我访问:

/subapp /子路径#will工作

/subapp/mapped_sub_path#将无法工作

这将工作得很好:

/应用

/另一

这是uwsgi日志: *上启动uWSGI 1.3(64位)[星期二12月4日18时41分52秒2012] 编译版本:4.1.2 20080704(Red Hat 4.1.2-52)2012年11月24日02:21:31 os:Linux-2.6.18-194.17.4.el5xen#1 SMP Mon Oct 25 16:36:31 EDT 2010 警告:你正在运行uWSGI作为根! (使用--uid标志) 你的流程数量限制32832 你的内存页面大小为4096字节 检测最大文件描述符数:1024 锁引擎:并行线程强大的互斥 uwsgi插座0绑定到UNIX地址/ tmp目录/app.sock fd 3 Python版本:2.7.3(默认,2012年10月30日,06:37:20)[GCC 4.1.2 20080704(Red Hat 4.1.2-52)] Python线程支持已禁用。你可以启用它 - 启用线程*

编辑:我启用了线程的--enable线程参数,并没有工作。

在此先感谢。

回答

1

该问题似乎与重新加载。

import web 


web.config.debug = False # turns off the reloader 


class subappcls: 
    def GET(self): 
     return "This will also be shown fine" 

sub_mappings = (
    "/subpath", subappcls 
) 

#subclass web app 
subwebapp = web.application(sub_mappings, globals()) 


#mapped class 
class mapped_cls: 
    def GET(self): 
     return "this mapped sub app will not be found" 


#Here I add mappings: 
subwebapp.add_mapping("/mapped_sub_path", mapped_cls) 


class appcls: 
    def GET(self): 
     return "main app" 


main_mappings = (
    "/subapp", subwebapp, 
    "/app", appcls, 
) 

mainwebapp = web.application(main_mappings, globals()) 


class indexcls: 
    def GET(self): 
     return "this will be shown just fine" 

mainwebapp.add_mapping("/another", indexcls) 


if __name__ == "__main__": 
    mainwebapp.run() 
else: 
    application = mainwebapp.wsgifunc() 

运行卷曲:

curl http://localhost:8080/subapp/mapped_sub_path 
this mapped sub app will not be found 
+0

还只是一个问题,你有没有试过这种在uwsgi如果运行在集成开发服务器(使用命令python code.py)下面的代码工作? – Uuid

+0

你是一个真正的,我有多个子应用程序,我只是关闭主要但不是为了子应用程序,这真的是修复,非常感谢! – Uuid

+0

我没有检查这个uwsgi,但它应该工作。将'web.config.debug'设置为'False'将全局关闭所有应用程序堆栈的重装器。 –

相关问题