uploading your fix to trunk.

On Jun 17, 8:50 am, amit <in4tu...@gmail.com> wrote:
> I am getting the same import error as the OP. The problem occurs when
> an external module calls __import__ but has passed globals=None. The
> following patch in gluon/custom_import.py fixes it for me, since in
> this case, web2py does not need to perform any customized import.
>

> 255c255
> <                 and not name.startswith("applications."):
> ---
>
> >                 and not name.startswith("applications.") and not 
> > globals==None:
>
> On Jun 17, 5:07 pm, selecta <gr...@delarue-berlin.de> wrote:
>
>
>
>
>
>
>
> > I also have problems importing pygments from the modules 
> > directoryhttp://jaguar.biologie.hu-berlin.de/~fkrause/web2py.app.pygments_test...
>
> > i downloaded pygments fromhttp://pypi.python.org/pypi/Pygments
>
> > and wrote in db.py
> > from pygments import highlight
> > from pygments.formatters import HtmlFormatter
> > import pygments.lexers
>
> > Traceback (most recent call last):
> >   File "/home/fkrause/Downloads/tmp/web2py/gluon/restricted.py", line
> > 192, in restricted
> >     exec ccode in environment
> >   File "/home/fkrause/Downloads/tmp/web2py/applications/pygments_test/
> > models/db.py", line 10, in <module>
> >     import pygments.lexers
> >   File "/home/fkrause/Downloads/tmp/web2py/gluon/custom_import.py",
> > line 271, in __call__
> >     globals, locals, fromlist, level)
> >   File "/home/fkrause/Downloads/tmp/web2py/gluon/custom_import.py",
> > line 299, in __import__dot
> >     locals, [name], level)
> >   File "/home/fkrause/Downloads/tmp/web2py/gluon/custom_import.py",
> > line 75, in __call__
> >     level)
> >   File "applications/pygments_test/modules/pygments/lexers/
> > __init__.py", line 222, in <module>
> >     oldmod = sys.modules['pygments.lexers']
> > KeyError: 'pygments.lexers'
>
> > On Jun 17, 10:57 am, selecta <gr...@delarue-berlin.de> wrote:
>
> > > I send you a test app that reproduces the error
> > > in case somebody else wants to test/debug you can download it 
> > > fromhttp://jaguar.biologie.hu-berlin.de/~fkrause/web2py.app.w2popenid_tes...
>
> > > On Jun 17, 4:32 am, Pierre Thibault <pierre.thibau...@gmail.com>
> > > wrote:
>
> > > > 2011/6/15 Massimo Di Pierro <massimo.dipie...@gmail.com>
>
> > > > > looking into this...
>
> > > > Still no news. Should we forget this issue? I really would like to 
> > > > debug but
> > > > I don't have enough information. It seems the bug is very rare.
>
> > > > > On Jun 15, 8:12 am, "mb_...@yahoo.fr" <mb_...@yahoo.fr> wrote:
> > > > > > I wanted to use the w2popenid example application from bitbucket
> > > > > > website :https://bitbucket.org/bottiger/web2py-openid/overview
> > > > > >  I have downloaded and placed the code in the applications 
> > > > > > directory.
> > > > > > I have changed in the models folder the file db.py: this line "from
> > > > > > applications.cas.modules.w2popenid import OpenIDLogin" is replaced
> > > > > > with this one "from w2popenid import OpenIDLogin" or this "from
> > > > > > applications.w2popenid.modules.import OpenIDLogin". But it don't
> > > > > > worked. I get to follow this trace
> > > > > > Traceback (most recent call last):
> > > > > >   File "/home/mamadou/Desktop/web2py/gluon/restricted.py", line 192,
> > > > > > in restricted
> > > > > >     exec ccode in environment
> > > > > >   File "/home/mamadou/Desktop/web2py/applications/w2popenid/models/
> > > > > > db.py", line 42, in <module>
> > > > > >     from testing import lala
> > > > > >   File "/home/mamadou/Desktop/web2py/gluon/custom_import.py", line
> > > > > > 280, in __call__
> > > > > >     fromlist, level)
> > > > > >   File "/home/mamadou/Desktop/web2py/gluon/custom_import.py", line 
> > > > > > 75,
> > > > > > in __call__
> > > > > >     level)
> > > > > >   File "/home/mamadou/Desktop/web2py/applications/w2popenid/modules/
> > > > > > testing.py", line 7, in <module>
> > > > > >     import openid.consumer.consumer
> > > > > >   File "/home/mamadou/Desktop/web2py/gluon/custom_import.py", line
> > > > > > 280, in __call__
> > > > > >     fromlist, level)
> > > > > >   File "/home/mamadou/Desktop/web2py/gluon/custom_import.py", line 
> > > > > > 75,
> > > > > > in __call__
> > > > > >     level)
> > > > > >   File "/usr/lib/pymodules/python2.7/openid/consumer/consumer.py",
> > > > > > line 197, in <module>
> > > > > >     from openid.consumer.discover import discover,
> > > > > > OpenIDServiceEndpoint, \
> > > > > >   File "/home/mamadou/Desktop/web2py/gluon/custom_import.py", line
> > > > > > 280, in __call__
> > > > > >     fromlist, level)
> > > > > >   File "/home/mamadou/Desktop/web2py/gluon/custom_import.py", line 
> > > > > > 75,
> > > > > > in __call__
> > > > > >     level)
> > > > > >   File "/usr/lib/pymodules/python2.7/openid/consumer/discover.py",
> > > > > > line 21, in <module>
> > > > > >     from openid.yadis.etxrd import nsTag, XRDSError, XRD_NS_2_0
> > > > > >   File "/home/mamadou/Desktop/web2py/gluon/custom_import.py", line
> > > > > > 280, in __call__
> > > > > >     fromlist, level)
> > > > > >   File "/home/mamadou/Desktop/web2py/gluon/custom_import.py", line 
> > > > > > 75,
> > > > > > in __call__
> > > > > >     level)
> > > > > >   File "/usr/lib/pymodules/python2.7/openid/yadis/etxrd.py", line 
> > > > > > 28,
> > > > > > in <module>
> > > > > >     ElementTree = importElementTree()
> > > > > >   File "/usr/lib/pymodules/python2.7/openid/oidutil.py", line 58, in
> > > > > > importElementTree
> > > > > >     ElementTree = __import__(mod_name, None, None, ['unused'])
> > > > > >   File "/home/mamadou/Desktop/web2py/gluon/custom_import.py", line
> > > > > > 258, in __call__
> > > > > >     globals.get("__file__", ""))
> > > > > > AttributeError: 'NoneType' object has no attribute 'get'
>
> > > > > > to fix i must modify the module custom_import in the web2py/gluon
> > > > > > folder.
> > > > > > starting line 256
>
> > > > > > try:
> > > > > >     caller_file_name = os.path.join(self.web2py_path,
> > > > > > \globals.get("__file__", ""))
> > > > > > except AttributeError:
> > > > > > caller_file_name = ""
>
> > > > --
>
> > > > A+
>
> > > > -------------
> > > > Pierre
> > > > My blog and profile
> > > > (http://pierrethibault.posterous.com)<http://pierrethibault.posterous.com>
> > > > YouTube page 
> > > > (http://www.youtube.com/user/tubetib)<http://www.youtube.com/user/tubetib>
> > > > Twitter (http://twitter.com/pierreth2) <http://twitter.com/pierreth2>

Reply via email to