PFG & collective.recaptcha : Errors Adding Captcha field / Configuring Captcha

Good morning!

A couple of collective.recaptcha related problems with PFG.

Version Overview

  • Plone 5.1.5 (5115)
  • CMF 2.2.12
  • Zope 2.13.27
  • Python 2.7.5+ (default, Feb 27 2014, 19:39:55) [GCC 4.8.1]
  • PIL 5.2.0 (Pillow)

KeyError: 'Interface `collective.recaptcha.settings.IRecaptchaSettings` defines a field `public_key`, for which there is no record.'

I do not see any place to enter the public key.
Seems like there should be a control panel for this, IIRC?
Thanks much for hints on this. As usual, these things pop-up when I'm very occasionally attempting a tweak or update to my sites. Can't seem to find much on this problem...

Also wondering why the built-in Plone contact form doesn't seem to include Captcha?

Traceback (innermost last):

* Module ZPublisher.Publish, line 138, in publish
* Module ZPublisher.mapply, line 77, in mapply
* Module ZPublisher.Publish, line 48, in call_object
* Module z3c.form.form, line 233, in __call__
* Module plone.z3cform.fieldsets.extensible, line 65, in update
* Module plone.z3cform.patch, line 30, in GroupForm_update
* Module z3c.form.group, line 132, in update
* Module z3c.form.form, line 129, in updateWidgets
* Module plone.app.registry.browser.controlpanel, line 50, in getContent
* Module plone.registry.registry, line 82, in forInterface

KeyError: 'Interface `collective.recaptcha.settings.IRecaptchaSettings` defines a field `public_key`, for which there is no record.'

This error attempting to add the Captcha Field (ie, click save after entering field name in the form)
Traceback (innermost last):

Module ZPublisher.Publish, line 138, in publish
Module ZPublisher.mapply, line 77, in mapply
Module ZPublisher.Publish, line 48, in call_object
Module Products.CMFFormController.FSControllerPageTemplate, line 91, in __call__
Module Products.CMFFormController.BaseControllerPageTemplate, line 32, in _call
Module Shared.DC.Scripts.Bindings, line 322, in __call__
Module Shared.DC.Scripts.Bindings, line 359, in _bindAndExec
Module Products.CMFCore.FSPageTemplate, line 237, in _exec
Module Products.CMFCore.FSPageTemplate, line 177, in pt_render
Module Products.PageTemplates.PageTemplate, line 87, in pt_render
Module zope.pagetemplate.pagetemplate, line 137, in pt_render
Module five.pt.engine, line 98, in __call__
Module z3c.pt.pagetemplate, line 163, in render
Module chameleon.zpt.template, line 261, in render
Module chameleon.template, line 191, in render
Module chameleon.template, line 171, in render
Module e1d3764fa33da0ae4516008675e56134.py, line 977, in render
Module dd8cf1877d10d10dde1c031bf35c5dcb.py, line 1223, in render_master
Module dd8cf1877d10d10dde1c031bf35c5dcb.py, line 420, in render_content
Module e1d3764fa33da0ae4516008675e56134.py, line 965, in __fill_content_core
Module e1d3764fa33da0ae4516008675e56134.py, line 332, in render_content_core
Module 0926406f2f6b0e443e62be9bad1e6c5b.py, line 368, in render_body
Module bc7a08316d41311b83501e0d0a2ef571.py, line 431, in render_edit
Module 5bdb5734f9ab464366091edc42c5d33b.py, line 655, in render_edit
Module bc7a08316d41311b83501e0d0a2ef571.py, line 141, in __fill_widget_body
Module five.pt.expressions, line 141, in __call__
Module Products.PageTemplates.Expressions, line 117, in render
Module collective.recaptcha.view, line 44, in image_tag
ValueError: archetypes.edit.beforefieldsets|nothing

 - Expression: "context/@@captcha/image_tag"
 - Filename:   ... oducts/PloneFormGen/skins/PloneFormGen/widget_captcha.pt
 - Location:   (line 24: col 40)
 - Source:     ... :replace="structure context/@@captcha/image_tag" /> 
                                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^
 - Expression: "provider:archetypes.edit.beforefieldsets|nothing"
 - Filename:   ... cts/PloneFormGen/skins/PloneFormGen/fg_edit_macros_p3.pt
 - Location:   (line 92: col 38)
 - Source:     ... tructure provider:archetypes.edit.beforefieldsets|nothing"
                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 - Arguments:  repeat: {...} (0)
               template: <ImplicitAcquisitionWrapper fg_base_view_p3 at 0xb399b3c4L>
               modules: <instance - at 0x98b06ac>
               portal_type: formcaptchafield
               here: <ImplicitAcquisitionWrapper please-confirm at 0xe36fc0c>
               js: <list - at 0xdcb7aac>
               portal: <ImplicitAcquisitionWrapper Fraterdeus at 0xe883eb4>
               user: <ImplicitAcquisitionWrapper - at 0xb399b784L>
               loop: {...} (1)
               nothing: <NoneType - at 0x833df84>
               target_language: <NoneType - at 0x833df84>
               container: <ImplicitAcquisitionWrapper Fraterdeus at 0xe883eb4>
               default: <object - at 0xb7557748L>
               fields: <tuple - at 0xdc2a0cc>
               request: <instance - at 0xb3c898acL>
               wrapped_repeat: <SafeMapping - at 0xcad8be4>
               traverse_subpath: <list - at 0xb3c9b8ccL>
               context: <ImplicitAcquisitionWrapper please-confirm at 0xe36fc0c>
               translate: <function translate at 0xe9f1844>
               root: <ImplicitAcquisitionWrapper Zope at 0xe883b44>
               options: {...} (2)
               css: <list - at 0xb3b8ca8cL>

Here's my Buildout:
[buildout]
############################################
# Plone Component Versions
# ------------------------
# This version of the Unified Installer has the components of Plone 5
# preloaded so that it can install without an Internet connection.
# If you want to update, uncomment the "http://..." line below,
# edit it to point to the current version URL, comment out the
# "versions.cfg" line and run "bin/buildout" while attached to the
# Internet. Generally, you only want to do that as part of a planned migration.
# Note that if you are updating components, you should also check the versions
# section at the end of this file, since recipes or components other than
# those of Zope and Plone may need updating at the same time.
#
extends =
base.cfg
# versions.cfg
http://dist.plone.org/release/5.1-latest/versions.cfg

# If you change your Plone version, you'll also need to update
# the repository link below.
find-links +=
    http://dist.plone.org/release/5.1-latest/
    
index =https://pypi.python.org/simple/

# If you try to start Zope as root, it will change user id to run as
# the effective user specified here. This user id must own the var directory
# of your buildout.
effective-user = plone_daemon
# This user will own the rest of the installation, and should be used to
# run buildout.
buildout-user = plone_buildout
# A flag to tell the Unified Installer whether or not to document sudo use.
need-sudo = yes

############################################
# Eggs
# ----
# Add an indented line to the eggs section for any Python
# eggs or packages you wish to include in your Plone instance.
#
# Note that versions may be specified here or in the [versions]
# section below. You should always specify versions that you know
# are compatible with the Plone release and at an acceptable
# development level.
#
# If you update to a later version of Plone, remove the hotfix.
#
eggs =
    Plone
    Pillow
    Products.RedirectionTool
    Products.PloneFormGen
    plone.app.mosaic
    plone.app.imagecropping
    collective.recaptcha
#    plone.formwidget.recaptcha
#    collective.plonetruegallery
#    collective.ptg.unitegallery
#    collective.ptg.carousel
#    collective.ptg.highslide
#    collective.ptg.contactsheet
#    collective.ptg.presentation
#    collective.ptg.fancybox
#    collective.ptg.supersized    

#    plonetheme.booster
#    plonetheme.business_casual

############################################
# ZCML Slugs
# ----------
# Some eggs need ZCML slugs to tell Zope to
# use them. This is increasingly rare.
zcml =
    collective.recaptcha

############################################
# Development Eggs
# ----------------
# You can use paster to create "development eggs" to
# develop new products/themes. Put these in the src/
# directory.
# You will also need to add the egg names in the
# eggs section above, and may also need to add them
# to the zcml section.
#
# Provide the *paths* to the eggs you are developing here:
develop =
#    src/my.package

############################################
# var Directory
# -------------
# Sets the target directory for the "var" components of the install such as
# database and log files.
#
var-dir=${buildout:directory}/var

############################################
# Backup Directory
# ----------------
# Sets the target directory for the bin/backup and bin/snapshotbackup
# commands. Default is inside this project's var directory, but ideally
# this should be on a separate volume or backup server.
#
backups-dir=${buildout:var-dir}

############################################
# Initial User
# ------------
# This is the user id and password that will be used to create the initial
# user id that will allow you to log in and create a Plone site. This only
# sets the initial password; it will not allow you to change an already
# existing password. If you change the admin password via the web interface,
# the one below will no longer be valid.
# If you find yourself locked out of your Zope/Python installation, you may
# add an emergency user via "bin/plonectl adduser".
user=admin:12349876

############################################
# Debug Options
# -------------
# Start Zope/Plone instances in "fg" mode to turn on debug mode;
# this will dramatically slow Plone.
#
# Add-on developers should turn deprecation warnings on
deprecation-warnings = off
# change verbose-security to "on" for useful security errors while developing
verbose-security = off

############################################
# Parts Specification
#--------------------
# Specifies the components that should be included in the buildout.
# Most are defined in the base.cfg extension; you may add your
# own if you need them at the end of this file.
parts =
    zeoserver
    client1
    backup
    zopepy
    unifiedinstaller
    precompiler
    setpermissions

############################################
# Major Parts
# ----------------------
# These common parts make use of sane base settings from
# base.cfg. To customize a part, just add whatever options
# you need. Read base.cfg for common settings.

[zeoserver]
<= zeoserver_base
recipe = plone.recipe.zeoserver
zeo-address = 127.0.0.1:8100

[client1]
<= client_base
recipe = plone.recipe.zope2instance
zeo-address = ${zeoserver:zeo-address}
http-address = 8080

############################################
# Versions Specification
# ----------------------
# Version information supplied here will "pin" Python packages to a particular
# version number, even when you use the "newest" flag running buildout.
# Specifying versions for all packages is a good idea and can prevent
# accidental changes when you add new packages to your buildout.
# Note that versions specified here will override those specified earlier
# in the configuration, including those from the Plone and Zope version
# config files.
#
[versions]
# Use the setuptools and zc.buildout versions that are
# available in our Python environment.
setuptools =
zc.buildout =


# prevents zope startup crash
plone.protect = 3.1.2

# mosaic pins
# if a package was released, update here!
# also, change the versions in buildout.coredev (5.1/5.2) version.cfg
# https://pypi.org/project/plone.app.mosaic/
# as of 18 dec 2018
plone.app.blocks        = 4.2.0
plone.app.drafts        = 1.1.2
plone.app.mosaic        = 2.1.1
plone.app.standardtiles = 2.3.1
plone.app.tiles         = 3.1.0
plone.tiles             = 2.1
plone.jsonserializer = 0.9.6
##
collective.recaptcha = 2.1.0


Products.DocFinderTab = 1.0.5
bobtemplates.plone = 1.0.3
buildout.sanitycheck = 1.0.2
collective.checkdocs = 0.2
collective.recipe.backup = 3.0.0
mr.bob = 0.1.2
pkginfo = 1.3.2
plone.recipe.unifiedinstaller = 4.3.2
requests-toolbelt = 0.6.2
twine = 1.7.2
zest.pocompile = 1.4
zest.releaser = 6.6.4

# Required by:
# Jinja2==2.8
MarkupSafe = 0.23

# Required by:
# clint==0.5.1
args = 0.1.0

# Required by:
# twine==1.7.2
clint = 0.5.1

# Required by:
# zest.releaser==6.6.4
colorama = 0.3.7

Does this happen on install ?


PS: I dont think you should use PloneFormGen with Plone >= 5.1, use collective.easyform instead (or you will have to stay with Archetype). You should also consider using Mosaic 2.2.1

This is an usability enhacement. The error should direct you where you should add this key. Reading the official docs:

Before the service will work, you must obtain a public and private key from reCAPTCHA  |  Google for Developers, and configure them at http://path/to/site/@@recaptcha-settings

You should:

Hi @espenmn
Thanks, as always for your reply.
No, it's not on install, when I try to add the captcha field to the form.
However, I seem to recall there was a control panel for Captcha where the keys would be pasted. That doesn't seem to show up on this site...
Once I've got my exhibition opened (Thurs evening! Everyone's invited :wink: I will go back to the server and update to collective.easyform and Mosaic 2.2.1, and see if anything changes.
Many thanks!
Peter

Hi @idgserpro!
Thanks for your reply.
Actually, I get an error attempting to access @@recaptcha-settings, so clearly, something else is not quite right!
I'll have some time to dig into it in a few days. Meanwhile, I'll live without :wink:
PF

After some additional tweaking of the buildout, swapping in collective.easyform , plone.formwidget.recaptcha, and collective.recaptchacontactform, I've resolved this problem.

Updated Mosaic to 2.2.1, but still some concerns with editing. I've opened a new thread for that.
Many thanks!

Is it possible that you upgraded a site that already had Mosaic and you have not run the upgrade profile from the (add-ons) control panel ?

Is it possible that you upgraded a site that already had Mosaic and you have not run the upgrade profile from the (add-ons) control panel ?

Not that I can see. This was a new Plone site on the server.
Mosaic was available as an add-on, but was not included in the initial instance.
When I updated Mosaic (per your suggestion when you saw the version in my buildout, and I should indeed do so on my other sites!), it was again available in the add-ons, when I went to install collective.easyform.
In my enthusiasm to update and upgrade, I installed Mosaic at that point, thinking it was an update!
Anyway, it's not a critical concern for me at this point, but I'm happy to continue to try to figure out what exactly has happened, since it could be a real problem for some other user.
I expect, if I hit this problem on a large site, I'd just be rolling back to an earlier backup.

The other point, I expect, is to only have in the buildout.cfg exactly the add-ons which are actually required by the site, which would have prevented my mistakenly installing Mosaic in this case.

Many thanks
PF