On 06/05/2017 10:43 AM, sp2l wrote: > When I ran "pip install recaptcha-client" > I got the following message: > > root@linux:# pip install recaptcha-client > Requirement already satisfied (use --upgrade to upgrade): recaptcha-client > in /usr/lib/python2.7/dist-packages > Cleaning up... > root@linux:# > > So, it appears that installing python-recaptcha, > module recaptcha-client got installed too. > > Therefore I startet to look at issue from a different point of view. > > The error message was: > admin(4038): from recaptcha.client import captcha > admin(4038): ImportError: No module named recaptcha.client > > Looking at the directory tree I noticed the following chain: > /usr / share / pyshared / recaptcha / client > > There _IS NEITHER_ recaptcha.client > _NOR_ recaptcha-client directory.
You need to understand how Python imports work. The recaptcha/client directory contains both __init__.py and captcha.py. Thus the from recaptcha.client import captcha statement will import the captcha.py file from recaptcha/client/ This is all as it should be. If the import fails it is because /usr/share/pyshared/ is not in Python's path. This is not too surprising as it this would normally be installed in /usr/local/lib/python2.7/dist-packages/ rather than /usr/share/pyshared/. > In patch supplied by this article: > https://www.dragonsreach.it/2014/05/03/adding-recaptcha-support-to-mailman/ > > there are twice two lines: > > sys.path.append("/usr/share/pyshared") > from recaptcha.client import captcha > > Changed them to read: > > sys.path.append("/usr/share/pyshared/recaptcha") > from client import captcha > > This way achieved success to have at least > properly displayed and working recaptcha box. OK. That's an acceptable work-around. Possibly the issue is there is no __init__.py file in the distributed recaptcha/ directory. Possibly just touch /usr/share/pyshared/recaptcha/__init__.py would also enable this. > Checked mailman error log file and noticed the following: > > Jun 05 20:20:03 2017 admin(23429): @@@@@@@@@@@@@@@@@@@. > admin(23429): [----- Mailman Version: 2.1.23 -----]. > admin(23429): [----- Traceback ------]. > admin(23429): Traceback (most recent call last): > admin(23429): File "/usr/local/mailman/scripts/driver", line 102, in > run_main > admin(23429): pkg = __import__('Mailman.Cgi', globals(), locals(), > [scriptname]) > admin(23429): File "/usr/local/mailman/Mailman/Cgi/subscribe.py", line 149 > admin(23429): if email == mlist.GetListEmail(): > admin(23429): ^ > admin(23429): IndentationError: unindent does not match any outer > indentation level In the process of applying the patch and/or editing the file, you have broken the formatting of /usr/local/mailman/Mailman/Cgi/subscribe.py The patched code beginning around line 130 should look like remote = os.environ.get('REMOTE_HOST', os.environ.get('REMOTE_ADDR', 'unidentified origin')) # recaptcha captcha_response = captcha.submit( cgidata.getvalue('recaptcha_challenge_field', ""), cgidata.getvalue('recaptcha_response_field', ""), mm_cfg.RECAPTCHA_PRIVATE_KEY, remote, ) if not captcha_response.is_valid: results.append(_('Invalid captcha')) # Was an attempt made to subscribe the list to itself? if email == mlist.GetListEmail(): syslog('mischief', 'Attempt to self subscribe %s: %s', email, remote) The lines remote = os.environ.get('REMOTE_HOST', # recaptcha captcha_response = captcha.submit( if not captcha_response.is_valid: # Was an attempt made to subscribe the list to itself? if email == mlist.GetListEmail(): in the above MUST be indented exactly 4 spaces, no tabs > At this point I am simply stucked... > All suggestions, advices are very welcomed. > > BTW, should recaptcha box be positioned > at the bottom of browser window? Questions such as this should be addressed to the author of the patch. See <https://wiki.list.org/x/12812344>. -- Mark Sapiro <m...@msapiro.net> The highway is for gamblers, San Francisco Bay Area, California better use your sense - B. Dylan ------------------------------------------------------ Mailman-Users mailing list Mailman-Users@python.org https://mail.python.org/mailman/listinfo/mailman-users Mailman FAQ: http://wiki.list.org/x/AgA3 Security Policy: http://wiki.list.org/x/QIA9 Searchable Archives: http://www.mail-archive.com/mailman-users%40python.org/ Unsubscribe: https://mail.python.org/mailman/options/mailman-users/archive%40jab.org