5
我有一个映射到此类的请求ChatMsg 它需要3个获取变量,用户名,房间名称和消息。但是它在这里的最后一行失败了。Google App Engine python - 自我未定义
class ChatMsg(webapp.RequestHandler): # this is line 239
def get(self):
username = urllib.unquote(self.request.get('username'))
roomname = urllib.unquote(self.request.get('roomname')) # this is line 242
当它试图分配ROOMNAME,它告诉我:
<type 'exceptions.NameError'>: name 'self' is not defined
Traceback (most recent call last):
File "/base/data/home/apps/chatboxes/1.341998073649951735/chatroom.py", line 239, in <module>
class ChatMsg(webapp.RequestHandler):
File "/base/data/home/apps/chatboxes/1.341998073649951735/chatroom.py", line 242, in ChatMsg
roomname = urllib.unquote(self.request.get('roomname'))
这到底是怎么回事,使自己没有定义
该代码看起来对我来说一目了然,你确定这不是服务器的同步问题吗?根据文件路径判断,您没有在本地运行该文件。 – 2010-05-16 20:49:01
除非有一些元类魔法,否则代码看起来不错。什么是“类型(ChatMsg)”? – jfs 2010-05-16 21:50:48
三重检查您的缩进。缩进差异在Python中非常重要。确保你没有混合的标签和空格。 – 2010-05-16 22:51:28