In the past, a couple of Plone sites we have built had large numbers of users for whom it was easier to store their details in an SQL Backend rather than Plone itself. When it came to bringing one of those system up-to-date it was appropriate to review the process and perhaps use a different approach such as a full-on LDAP deployment. During this review process, we learned how to deploy a new product and figured a solution to a possible use case.
Unfortunately the help documents on the web did not help us install this product and it took some research to discover much simpler instructions buried deep in the plone.users mailinglist ; so deep it remains hidden. Here is what we did:
pas.plugins.sqlalchemy to the eggs section in
pas.plugins.sqlalchemy to the zcml section in
collective.saconnect did not seem to work for us or at least was not helpful so do not install this product
add a definition to the instance section in your
buildout.cfg appropriately modified to point to the database you want to use; best to make sure you can get this to connect first (see code below)
zcml-additional =configure xmlns="http://namespaces.zope.org/zope" < xmlns:db="http://namespaces.zope.org/db"> include package="z3c.saconfig" file="meta.zcml" /> <db:engine xmlns="http://namespaces.zope.org/db" < name="pas" url="mysql://user:password <at> host/database" /> db:session xmlns="http://namespaces.zope.org/db" < name="pas.plugins.sqlalchemy" engine="pas" /> configure></
you can now startup your Plone instance
from the Plone control panel, add the PAS SQL Plugin product: this step should both connect to the database and create the database schema with empty tables
to activate the plugin, access the ZMI and navigate to the acl_users folder and the plugins sub-folder. Review each plugin-type and if an sql option is available, change its precedence to suit your purposes.
Provided you have set the precedence of sql in the User Adder plugins (step 7) you can add new users and they will be stored in your SQL database. Notice that the settings in step 4 apply throughout an instance. If you have several Plone instances within a single Zope instance, then each Plone instance with the PAS SQL Plugin activated will share the same user SQL database - as in the Use Case below.
Note: the following notes only apply for a group of Plone sites; although the use case may be general, this solution is specific to Plone
Suppose you require a number of related sites all of which relate broadly to the same group of users:
In your sites, you want to allow members to be able to logon and authenticate themselves. Then depending on the site and the specific user, various roles can be assigned to allow access to different types of content. When deploying this plugin, user information is stored in the database but user and group permissions remains in Plone. Using this behaviour we can use group definitions to control who can do what in specific sites; all with a minimum of tweaking the Plone instances. First the minimal changes:
Having done all this, you should now get the following behaviour
These behaviours are easily managed simply by adding users to one or more groups. Further, a new user only needs added in one site and usually Group membership can be assigned at that time (except for Groups which are specific to individual sites). Active Membership can also be controlled by an external application updating the SQL database independent of any Plone instance i.e. for lapsed members, remove their appropriate Group membership via the database. This procedure will affect all related sites immediately without having to do anything else.