[Python-es] Importar libreria Cliente Captcha

Mario Alfonso Saucedo Gomez msagom en gmail.com
Mar Sep 9 18:12:54 CEST 2014


Buenos días a todos, reciban un cordial saludo.

Si efectivamente como lo menciona carlos hubo ese cambio en dicha librería,
lo que me impresiona es que estoy utilizando un api de google e instalé la
librería de referencia, me tomé la tarea de revisar el código y el error se
presenta en captcha.py del cliente que instalé donde hace el  import
urllib2, urllib y en el código utiliza lo siguiente:

    params = urllib2.urlencode ({
            'privatekey': encode_if_necessary(private_key),
            'remoteip' :  encode_if_necessary(remoteip),
            'challenge':  encode_if_necessary(recaptcha_challenge_field),
            'response' :  encode_if_necessary(recaptcha_response_field),
            })

    request = urllib2.Request (
        url = "http://%s/recaptcha/api/verify" % VERIFY_SERVER,
        data = params,
        headers = {
            "Content-type": "application/x-www-form-urlencoded",
            "User-agent": "reCAPTCHA Python"
            }
        )

La solución que hice fue renombrar esa librería y hasta el momento me
funcionó estoy en fase de pruebas para ver que defecto detecto a nivel de
funcionalidad cualquier cosa adicional les informo.


Saludos,

2014-09-08 10:43 GMT-05:00 Carlos Zuniga <carlos.zun en gmail.com>:

> On Sun, Sep 7, 2014 at 2:06 PM, Mario Alfonso Saucedo Gomez
> <msagom en gmail.com> wrote:
> >
> > Buenos días,
> >
> > Quiero consultarles si alguno ha integrado el cliente en mención para
> > validar esto en un formulario contacto. hice la instalación en mi
> ambiente
> > del cliente, generé los respectivos modelos, vistas y formularios pero
> > cuando ingreso esta línea en view.py no me importa la librería alguién me
> > puede orientar que me falta.
> >
> > Versión django 1.6 Python 3.4.1
> >
> > from recaptcha.client import captcha
> >
> > remito el log de errores
> >
> > 0 errors found
> > September 07, 2014 - 14:02:10
> > Django version 1.6, using settings 'AweC.settings'
> > Starting development server at http://127.0.0.1:8000/
> > Quit the server with CTRL-BREAK.
> > Internal Server Error: /
> > Traceback (most recent call last):
> >   File "C:\Python34\lib\site-packages\django\core\handlers\base.py", line
> > 101, in get_response
> >     resolver_match = resolver.resolve(request.path_info)
> >   File "C:\Python34\lib\site-packages\django\core\urlresolvers.py", line
> > 320, in resolve
> >     sub_match = pattern.resolve(new_path)
> >   File "C:\Python34\lib\site-packages\django\core\urlresolvers.py", line
> > 222, in resolve
> >     return ResolverMatch(self.callback, args, kwargs, self.name)
> >   File "C:\Python34\lib\site-packages\django\core\urlresolvers.py", line
> > 229, in callback
> >     self._callback = get_callable(self._callback_str)
> >   File "C:\Python34\lib\site-packages\django\utils\functional.py", line
> 32,
> > in wrapper
> >     result = func(*args)
> >   File "C:\Python34\lib\site-packages\django\core\urlresolvers.py", line
> 96,
> > in get_callable
> >     mod = import_module(mod_name)
> >   File "C:\Python34\lib\importlib\__init__.py", line 109, in
> import_module
> >     return _bootstrap._gcd_import(name[level:], package, level)
> >   File "<frozen importlib._bootstrap>", line 2254, in _gcd_import
> >   File "<frozen importlib._bootstrap>", line 2237, in _find_and_load
> >   File "<frozen importlib._bootstrap>", line 2226, in
> > _find_and_load_unlocked
> >   File "<frozen importlib._bootstrap>", line 1200, in _load_unlocked
> >   File "<frozen importlib._bootstrap>", line 1129, in _exec
> >   File "<frozen importlib._bootstrap>", line 1471, in exec_module
> >   File "<frozen importlib._bootstrap>", line 321, in
> > _call_with_frames_removed
> >   File "C:/Developer/Python/AweC\WebHome\views.py", line 4, in <module>
> >     from recaptcha.client import captcha
> >   File "C:\Python34\lib\site-packages\recaptcha\client\captcha.py", line
> 1,
> > in <module>
> >     import urllib2, urllib
> > ImportError: No module named 'urllib2'
> > Traceback (most recent call last):
> >   File "C:\Python34\lib\site-packages\django\core\handlers\base.py", line
> > 101, in get_response
> >     resolver_match = resolver.resolve(request.path_info)
> >   File "C:\Python34\lib\site-packages\django\core\urlresolvers.py", line
> > 320, in resolve
> >     sub_match = pattern.resolve(new_path)
> >   File "C:\Python34\lib\site-packages\django\core\urlresolvers.py", line
> > 222, in resolve
> >     return ResolverMatch(self.callback, args, kwargs, self.name)
> >   File "C:\Python34\lib\site-packages\django\core\urlresolvers.py", line
> > 229, in callback
> >     self._callback = get_callable(self._callback_str)
> >   File "C:\Python34\lib\site-packages\django\utils\functional.py", line
> 32,
> > in wrapper
> >     result = func(*args)
> >   File "C:\Python34\lib\site-packages\django\core\urlresolvers.py", line
> 96,
> > in get_callable
> >     mod = import_module(mod_name)
> >   File "C:\Python34\lib\importlib\__init__.py", line 109, in
> import_module
> >     return _bootstrap._gcd_import(name[level:], package, level)
> >   File "<frozen importlib._bootstrap>", line 2254, in _gcd_import
> >   File "<frozen importlib._bootstrap>", line 2237, in _find_and_load
> >   File "<frozen importlib._bootstrap>", line 2226, in
> > _find_and_load_unlocked
> >   File "<frozen importlib._bootstrap>", line 1200, in _load_unlocked
> >   File "<frozen importlib._bootstrap>", line 1129, in _exec
> >   File "<frozen importlib._bootstrap>", line 1471, in exec_module
> >   File "<frozen importlib._bootstrap>", line 321, in
> > _call_with_frames_removed
> >   File "C:/Developer/Python/AweC\WebHome\views.py", line 4, in <module>
> >     from recaptcha.client import captcha
> >   File "C:\Python34\lib\site-packages\recaptcha\client\captcha.py", line
> 1,
> > in <module>
> >     import urllib2, urllib
> > ImportError: No module named 'urllib2'
> >
>
> En Python3 urllib2 se convirtió en urllib a secas. Parece que el
> modulo que quieres usar es para Python2.
> _______________________________________________
> Python-es mailing list
> Python-es en python.org
> https://mail.python.org/mailman/listinfo/python-es
> FAQ: http://python-es-faq.wikidot.com/
>



-- 
Cordialmente,

Mario Alfonso Saucedo Gómez
------------ próxima parte ------------
Se ha borrado un adjunto en formato HTML...
URL: <http://mail.python.org/pipermail/python-es/attachments/20140909/6ac67831/attachment.html>


Más información sobre la lista de distribución Python-es