闷啊,为什么我很多example都跑不通,是我环境的问题?

1 view
Skip to first unread message

HoLin

unread,
Mar 28, 2009, 3:16:17 AM3/28/09
to eurasia-users
HoLin:tmp holin$ python hello.py
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/2.5/lib/
python2.5/site-packages/eurasia-3.0.0a6-py2.5.egg/eurasia/socket2.py",
line 558, in mainloop0
stackless.run()
File "hello.py", line 9, in handler
if not os.uri.exists(filename): # 文件不存在 , 返回 404 (未找到)
AttributeError: 'module' object has no attribute 'uri'
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/2.5/lib/
python2.5/site-packages/eurasia-3.0.0a6-py2.5.egg/eurasia/socket2.py",
line 558, in mainloop0
stackless.run()
File "hello.py", line 9, in handler
if not os.uri.exists(filename): # 文件不存在 , 返回 404 (未找到)
AttributeError: 'module' object has no attribute 'uri'
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/2.5/lib/
python2.5/site-packages/eurasia-3.0.0a6-py2.5.egg/eurasia/socket2.py",
line 558, in mainloop0
stackless.run()
File "hello.py", line 9, in handler
if not os.uri.exists(filename): # 文件不存在 , 返回 404 (未找到)
AttributeError: 'module' object has no attribute 'uri'
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/2.5/lib/
python2.5/site-packages/eurasia-3.0.0a6-py2.5.egg/eurasia/socket2.py",
line 558, in mainloop0
stackless.run()
File "hello.py", line 9, in handler
if not os.uri.exists(filename): # 文件不存在 , 返回 404 (未找到)
AttributeError: 'module' object has no attribute 'uri'



^CHoLin:tmp holin$ python hello.py
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/2.5/lib/
python2.5/site-packages/eurasia-3.0.0a6-py2.5.egg/eurasia/socket2.py",
line 558, in mainloop0
stackless.run()
File "hello.py", line 9, in handler
if not os.uri.exists(filename): # 文件不存在 , 返回 404 (未找到)
AttributeError: 'module' object has no attribute 'uri'
^CHoLin:tmp holin$
HoLin:tmp holin$
HoLin:tmp holin$
HoLin:tmp holin$ python hello.py
^CHoLin:tmp holin$ python hello.py
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/2.5/lib/
python2.5/site-packages/eurasia-3.0.0a6-py2.5.egg/eurasia/socket2.py",
line 558, in mainloop0
stackless.run()
File "hello.py", line 21, in handler
fd = SimpleUpload(httpfile)
File "/Library/Frameworks/Python.framework/Versions/2.5/lib/
python2.5/site-packages/eurasia-3.0.0a6-py2.5.egg/eurasia/cgietc.py",
line 105, in __init__
raise IOError
IOError





^CHoLin:tmp holin$
HoLin:tmp holin$
HoLin:tmp holin$
HoLin:tmp holin$ sudo python hello.py
Password:




Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/2.5/lib/
python2.5/site-packages/eurasia-3.0.0a6-py2.5.egg/eurasia/socket2.py",
line 558, in mainloop0
stackless.run()
File "hello.py", line 21, in handler
fd = SimpleUpload(httpfile)
File "/Library/Frameworks/Python.framework/Versions/2.5/lib/
python2.5/site-packages/eurasia-3.0.0a6-py2.5.egg/eurasia/cgietc.py",
line 105, in __init__
raise IOError
IOError
^CHoLin:tmp holin$ sudo python hello.py
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/2.5/lib/
python2.5/site-packages/eurasia-3.0.0a6-py2.5.egg/eurasia/socket2.py",
line 558, in mainloop0
stackless.run()
File "hello.py", line 23, in handler
session[uid] = Form(request) # 在 session 中保存本次的表单数据
NameError: global name 'request' is not defined

沈崴

unread,
Mar 28, 2009, 4:01:52 AM3/28/09
to eurasia-users
关于 alpha6 已知 bug 已经进行了修复 (包括文档), 你可以从这里下载 (这个已经公告了):
http://eurasia.googlecode.com/files/Eurasia-3.0.0a6-snapshot.tar.bz2
http://eurasia.googlecode.com/files/eurasiaguide-3.0.0a6-snapshot.tar.bz2

至于 hello.py 的报错, 需要更详细的信息才能定位。

On Mar 28, 3:16 pm, HoLin <holin...@gmail.com> wrote:
> HoLin:tmp holin$ python hello.py

> ...

HoLin

unread,
Mar 28, 2009, 4:22:36 AM3/28/09
to eurasi...@googlegroups.com
谢谢你的回复。

我上午下的版本,Eurasia-3.0.0a6-snapshot.tar.bz2, 是最新的了。

关于hello.py的内容,我是直接帖了guide(eurasiaguide-3.0.0a6-snapshot)里的代码。

hello.py文件:

#!/usr/bin/python2.5
#-*- coding: utf-8 -*-

import os.path
from eurasia import config, mainloop

def handler(httpfile):
    filename = '/www' + httpfile.path_info

    if not os.uri.exists(filename): # 文件不存在  , 返回 404 (未找到)
        httpfile.status = 404
        httpfile.write('<h1>Not Found</h1>')
        return httpfile.close()

    if os.path.isdir(filename):     # 请求的是目录, 返回 403 (拒绝访问)
        httpfile.status = 403
        httpfile.write('<h1>Forbidden</h1>')
        return httpfile.close()

    try:
        data = open(filename).read()
    except (IOError, OSError):      # 文件读取错误, 返回 500
        httpfile.status = 500
        httpfile.write('<h1>Internal Server Error</h1>')
        return httpfile.close()

    # 正确返回文件内容, 因为设定了 Content-Type 为 application/octet-stream,
    # 浏览器将提示用户是否下载该文件, 而不是直接显示出来
    httpfile['Content-Type'] = 'application/octet-stream'
    httpfile.write(data)
    httpfile.close()

config(handler=handler, port=8080)
mainloop()


访问了地址:http://localhost:8080/ddd

出错:


HoLin:tmp holin$ python hello.py
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/eurasia-3.0.0a6-py2.5.egg/eurasia/socket2.py", line 558, in mainloop0

    stackless.run()
  File "hello.py", line 9, in handler
    if not os.uri.exists(filename): # 文件不存在  , 返回 404 (未找到)
AttributeError: 'module' object has no attribute 'uri'



我想可能是我系统配置的问题,可能python2.5没装好。 我再看看


2009/3/28 沈崴 <wile...@gmail.com>



--
Regards
HoLin

沈崴

unread,
Mar 28, 2009, 4:34:46 AM3/28/09
to eurasia-users
这是文档中的一个 bug, 里面 os.uri.exists(filename) 应为 os.path.exists(filename)。
下面是修改以后的样子, 我已经测试通过:

#!/home/william/Desktop/Stackless-2.5.2/bin/python2.5
#-*- coding: utf-8 -*-
import os.path
from eurasia import config, mainloop

def handler(httpfile):
filename = '/var/www' + httpfile.path_info
if not os.path.exists(filename): # 文件不存在 , 返回 404 (未找到)
httpfile.status = 404
httpfile.write('<h1>Not Found</h1>')
return httpfile.close()

if os.path.isdir(filename): # 请求的是目录, 返回 403 (拒绝访问)
httpfile.status = 403
httpfile.write('<h1>Forbidden</h1>')
return httpfile.close()

try:
data = open(filename).read()
except (IOError, OSError): # 文件读取错误, 返回 500
httpfile.status = 500
httpfile.write('<h1>Internal Server Error</h1>')
return httpfile.close()

# 正确返回文件内容, 因为设定了 Content-Type 为 application/octet-stream,
# 浏览器将提示用户是否下载该文件, 而不是直接显示出来
httpfile['Content-Type'] = 'application/octet-stream'
httpfile.write(data)
httpfile.close()

config(handler=handler, port=8080)
mainloop()

这部份内容我已经提交至 svn, 将于下一个积累性更新 (alpha6.2) 中发布, 谢谢你的报告。
> 2009/3/28 沈崴 <wilei...@gmail.com>
>
> > 关于 alpha6 已知 bug 已经进行了修复 (包括文档), 你可以从这里下载 (这个已经公告了):
> > http://eurasia.googlecode.com/files/Eurasia-3.0.0a6-snapshot.tar.bz2
>
> >http://eurasia.googlecode.com/files/eurasiaguide-3.0.0a6-snapshot.tar...

Zoom.Quiet

unread,
Mar 28, 2009, 4:39:23 AM3/28/09
to eurasi...@googlegroups.com
2009/3/28 沈崴 <wile...@gmail.com>:

>
> 这是文档中的一个 bug, 里面 os.uri.exists(filename) 应为 os.path.exists(filename)。

"文档中的bug..." 嗯嗯嗯,俺都习惯看文档不对味时看代码了,,
但是,总之是问题哪,,

--
http://zoomquiet.org
'''过程改进乃是催生可促生靠谱的人的组织!'''
金山常年招聘Py/C++人才! http://bit.ly/UoTV 简历直投俺就成;-)

沈崴

unread,
Mar 28, 2009, 4:46:46 AM3/28/09
to eurasia-users
On Mar 28, 4:39 pm, "Zoom.Quiet" <zoom.qu...@gmail.com> wrote:
> 2009/3/28 沈崴 <wilei...@gmail.com>:

>
> > 这是文档中的一个 bug, 里面 os.uri.exists(filename) 应为 os.path.exists(filename)。
>
> "文档中的bug..." 嗯嗯嗯,俺都习惯看文档不对味时看代码了,,
> 但是,总之是问题哪,,

呵呵, 文档里 os.uri.exists 这个确实比较 囧 ...
eurasia 里 httpfile.uri 和 httpfile.path 可以通用, 而 os.path 就不行了撒~~`

> > 下面是修改以后的样子, 我已经测试通过:
> > ...


> > 这部份内容我已经提交至 svn, 将于下一个积累性更新 (alpha6.2) 中发布, 谢谢你的报告。
>
> > On Mar 28, 4:22 pm, HoLin <holin...@gmail.com> wrote:
> >> 谢谢你的回复。
>
> >> 我上午下的版本,Eurasia-3.0.0a6-snapshot.tar.bz2, 是最新的了。
>
> >> 关于hello.py的内容,我是直接帖了guide(eurasiaguide-3.0.0a6-snapshot)里的代码。
>
> >> hello.py文件:

HoLin

unread,
Mar 28, 2009, 5:14:57 AM3/28/09
to eurasi...@googlegroups.com
可以了。我试试其他的。

2009/3/28 沈崴 <wile...@gmail.com>



--
Regards
HoLin
Reply all
Reply to author
Forward
0 new messages