Zach Dwiel
unread,Mar 25, 2011, 6:33:13 PM3/25/11Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Akara Developers
I'm getting strange bugs from this code:
#!/usr/bin/env python2.6
import web
from amara import bindery
urls = (
'/(.*)', 'index'
)
app = web.application(urls, globals())
class index:
def POST(self, x):
return 'hello world'
if __name__ == "__main__":
app.run()
traceback:
Traceback (most recent call last):
File "<string>", line 1, in <module>
ImportError: cannot import name pystone
Traceback (most recent call last):
File "/home/plotwatt/lib/python2.6/site-packages/web.py-0.34-
py2.6.egg/web/application.py", line 240, in process
return p(lambda: process(processors))
File "/home/plotwatt/lib/python2.6/site-packages/web.py-0.34-
py2.6.egg/web/application.py", line 560, in processor
h()
File "/home/plotwatt/lib/python2.6/site-packages/web.py-0.34-
py2.6.egg/web/application.py", line 649, in __call__
self.check(mod)
File "/home/plotwatt/lib/python2.6/site-packages/web.py-0.34-
py2.6.egg/web/application.py", line 653, in check
mtime = os.stat(mod.__file__).st_mtime
File "/home/plotwatt/lib/python2.6/site-packages/Amara-2.0a4-py2.6-
linux-i686.egg/amara/lib/importutil.py", line 215, in __getattribute__
module = __import__(realname, {}, {}, [name])
File "/home/plotwatt/lib/python2.6/site-packages/Amara-2.0a4-py2.6-
linux-i686.egg/amara/test/__init__.py", line 37, in <module>
def func_not_to_exceed_pystone(max_num_pystones,
current_pystone=local_pystone()):
File "/home/plotwatt/lib/python2.6/site-packages/Amara-2.0a4-py2.6-
linux-i686.egg/amara/test/__init__.py", line 34, in local_pystone
return eval(result)
File "<string>", line 0
^
SyntaxError: unexpected EOF while parsing
One fix is to edit the function proxy_module in the file: Amara-2.0a4-
py2.6-linux-i686.egg/amara/lib/importutil.py
def proxy_module(fullname, realname):
class moduleproxy(types.ModuleType):
def __getattribute__(self, name):
if realname not in sys.modules:
# Load the module
+ if name == '__file__' :
+ return __file__
module = __import__(realname, {}, {}, [name])
# Replace ourselves in `sys.modules`
sys.modules[fullname] = module
else:
module = sys.modules[realname]
return module.__getattribute__(name)
def __repr__(self):
return "<moduleproxy '%s' to '%s'>" % (fullname, realname)
module = sys.modules[fullname] = moduleproxy(fullname)
return module
the problem is that web.py tries to check to see if amara has changed
and looks up amara's __file__ first which fires this __getattribute__.
This may not be a problem with the newest versions in akara, but it is
still a problem in the latest I got from easy_install
zach