strange bug when using Amara with web.py

6 views
Skip to first unread message

Zach Dwiel

unread,
Mar 25, 2011, 6:33:13 PM3/25/11
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

Luis Miguel Morillas

unread,
Mar 26, 2011, 11:19:32 AM3/26/11
to akar...@googlegroups.com
2011/3/25 Zach Dwiel <zdw...@gmail.com>:

Hello, Zach,

What amara version are you using?

>>> import amara
>>> amara.__version__
'2.0a5'

Saludos,

-- luismiguel

> --
> You received this message because you are subscribed to the Google Groups "Akara Developers" group.
> To post to this group, send email to akar...@googlegroups.com.
> To unsubscribe from this group, send email to akara-dev+...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/akara-dev?hl=en.
>
>

Luis Miguel Morillas

unread,
Oct 1, 2011, 2:48:09 AM10/1/11
to Zach Dwiel, akar...@googlegroups.com
I can't reproduce the error. Try to upgrade the package because there
is a new amara at Pypi: http://pypi.python.org/pypi/Amara/2.0.0a6

Regards,

-- luismiguel

2011/10/1 Zach Dwiel <zdw...@gmail.com>:
> The version that I am running is 2.0a4 (from easy_install)
>
> Wow, just ran into this problem again and found my thread through
> searching for a solution

Reply all
Reply to author
Forward
0 new messages