On Monday, June 4, 2018 at 10:54:01 AM UTC-7, Suhas Jadhav wrote:
>
> Yes, I say the documentation. But issues here is urllib2 works well from 
> my python console.
> the error happens when web2py tries to call it.
> My code is not calling it directly. I believe ldap_auth library calling 
> urllib2 
> internally and faile.
>
> Thanks,
> Suhas
>

Your sample in the original post showed YOU importing urllib2.  My scan of 
gluon/contrib/login_methods/ldap_auth.py doesn't find an import of urllib2.

/dps
 

>
> On Monday, 4 June 2018 06:44:37 UTC-7, Suhas Jadhav wrote:
>>
>> Hi,
>> I am getting error ModuleNotFoundError: No module named 'urllib2'
>>
>> My Code is 
>>
>> def test():
>>     import ldap
>>     from urllib.request import urlopen
>>     import urllib2
>>     import urllib
>>    
>>  
>> auth.settings.actions_disabled=['register','change_password','request_reset_password','retrieve_username','profile']
>>     auth.settings.remember_me_form = False
>>     from gluon.contrib.login_methods.ldap_auth import ldap_auth
>>     auth.settings.login_methods = [ldap_auth(mode='ad',
>>     server='sever.com',
>>     base_dn='dc="DC,dc=corp,dc="DC",dc=com')]
>>     
>>     from gluon.contrib.login_methods.basic_auth import basic_auth
>>     auth.settings.login_methods.append(
>>     basic_auth('https://example.com'))
>>     return locals()
>>
>>
>> ERROR
>>
>> Traceback (most recent call last):
>>   File "C:\WEB2PY\web2py\gluon\custom_import.py", line 77, in custom_importer
>>     return NATIVE_IMPORTER(oname, globals, locals, fromlist, level)
>> ModuleNotFoundError: No module named 'urllib2'
>>
>> During handling of the above exception, another exception occurred:
>>
>> Traceback (most recent call last):
>>   File "C:\WEB2PY\web2py\gluon\custom_import.py", line 90, in custom_importer
>>     result = result or sys.modules[modules_prefix+'.'+itemname]
>> KeyError: 'applications.welcome.modules.urllib2'
>>
>>
>> All the imports work from python terminal but not from web2py
>> import ldap
>>     from urllib.request import urlopen
>>     import urllib2
>>     import urllib
>>
>>
>> VERSION
>> web2py™ Version 2.16.1-stable+timestamp.2017.11.14.05.54.25
>>
>> PYTHON Python 3.6.2
>>
>>
>> Any solution or workaround?
>>
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to