Hello,
I need help developing a PAS plugin for Plone6. Could someone point me to a simple example? The book Professional Plone 4 development included an example for Facebook authentication, but it seems no longer works with Plone 6. (This plugin code is available here.)
I am stuck at the very beginning, where I need to register my plugin so that it is accessible in acl_users
.
Following the example from the book, I added the following in configure.zcml
:
<five:registerClass
class=".pasplugin.MyPASPlugin"
meta_type="MyPASPlugin"
permission="zope2.ManageUsers"
addview="my-pas-plugin"
/>
<pas:registerMultiPlugin
meta_type="MyPASPlugin"
/>
<browser:page
name="my-pas-plugin"
for="zope.browser.interfaces.IAdding"
class=".pasplugin.AddForm"
permission="zope2.ViewManagementScreens"
/>
and in pasplugin.py
I have:
@implementer(IAuthenticationPlugin)
class MyPASPlugin(BasePlugin):
"""My PAS plugin"""
def authenticateCredentials(self, credentials):
# some code non-important for this post, but basically:
login = credentials.get('login')
return login, login
class AddForm(BrowserView):
""" Add view to allow the plugin to be added through ZMI
"""
template = ViewPageTemplateFile('addform.pt')
def __call__(self):
print("here")
if 'form.button.Add' in self.request.form:
name = self.request.form.get('id')
title = self.request.form.get('title')
plugin = MyPASPlugin(name, title)
self.context.context[name] = plugin
self.request.response.redirect(
self.context.absolute_url() + '/manage_workspace?manage_tabs_message="Plugin+added.')
else:
return self.template()
The addform.pt
template is exactly the same as in the book.
After installing it, I can see the plugin in the Select type to add
menu on the acl_users
page:
but when I select it, I am forwarded to this address
http://localhost:8080/Plone/acl_users/+/my-pas-plugin
which shows the message that
This page does not seem to exist…
Trying to determine the cause of this error, I checked the source code of the Select type to add
menu items and noticed that the page address for my plugin differs from the other entries (i.e. it does not start with manage_addProduct
):
<option data-dialog="modal" value="manage_addProduct/OFSP/folderAdd">Folder</option>
<option data-dialog="modal" value="manage_addProduct/OFSP/addOrderedFolder">Folder (Ordered)</option>
<option data-dialog="modal" value="+/my-pas-plugin">MyPASPlugin</option>
Does this indicate a problem? What am I doing wrong?