[Zope-PAS] Re: Duplicate pulgin types created by PluginRegistry.exportimport._updatePluginRegistry

Tres Seaver tseaver at palladion.com
Tue Dec 19 09:54:52 EST 2006


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Ross Patterson wrote:
> I recently wired together the GenericSetup handlers from PAS in an
> extension profile for another product.  This way I can support fully
> declaritive import/export steps for setting up a PAS user folder
> within a CMF GS profile using the PAS subdirectory.  As such we can
> avoid the declaritive abuse of GS used in borg, membrane, remember,
> etc..
> 
> It all worked great with a minimum of code in the other product with
> one exception.  If a plugin type and active plugins for that type have
> been configured previously (whether by a GS profile or not) then
> registering the plugin type again with a new list of active plugins
> will result in duplicates in registry._plugin_types (as in
> acl_users.plugins._plugin_types).  This doesn't actually break any
> functionality but results in duplicates in the PAS ZMI.
> 
> Attached is a small patch that avoids this rather simply.  I'd love to
> see it merged so I don't have to maintain changed copies in my own
> product to have extension profiles that modify a PAS UF configuration.
> 
> 
> 
> ------------------------------------------------------------------------
> 
> Index: exportimport.py
> ===================================================================
> --- exportimport.py	(revision 71599)
> +++ exportimport.py	(working copy)
> @@ -81,7 +81,9 @@
>  
>      for info in reg_info['plugin_types']:
>          iface = _resolveDottedName(info['interface'])
> -        registry._plugin_types.append(iface)
> +        # Avoid duplicate plugin types
> +        if iface not in registry._plugin_types:
> +            registry._plugin_types.append(iface)
>          registry._plugin_type_info[iface] = {'id': info['id'],
>                                               'title': info['title'],
>                                               'description': info['description'],
> 
> 
> ------------------------------------------------------------------------

Thanks! Can you please add to the PAS collector so we don't lose the patch:

  http://www.zope.org/Collectors/PAS


> I've also attached the module within my product's exportimport package
> and the overrides.zcml used in case this is of interest to anyone.
> 
> 
> 
> ------------------------------------------------------------------------
> 
> """GenericSetup export/import handlers for setting up
> PluggableAuthService plugins in acl_users."""
> 
> from StringIO import StringIO
> 
> from Persistence import PersistentMapping
> 
> from Products.GenericSetup.interfaces import IFilesystemImporter
> from Products.GenericSetup.interfaces import IFilesystemExporter
> from Products.GenericSetup.utils import _resolveDottedName
> from Products.GenericSetup.content import FauxDAVRequest
> from Products.GenericSetup.content import FauxDAVResponse
> 
> from Products.PluginRegistry.exportimport import PluginRegistryFileExportImportAdapter as Base
> from Products.PluginRegistry.exportimport import PluginRegistryImporter
> from Products.PluginRegistry.exportimport import _FILENAME
> from Products.CMFCore.utils import getToolByName
> 
> # TODO: Wire up importers that don't remove objects not specified in
> # either .preserve or .objects
> 
> def importPAS(context):
>     """Import and setup any PAS plugins."""
>     uf = getToolByName(context.getSite(), 'acl_users')
>     IFilesystemImporter(uf).import_(context, 'PAS', True)
> 
> def exportPAS(context):
>     """Export any PAS plugins with configurations."""
>     uf = getToolByName(context.getSite(), 'acl_users')
>     IFilesystemExporter(uf).export(context, 'PAS', True)

I don't understand the need for this handler, or why your overrides.zcml
uses it for IPluginRegistry.  The "normal" handers for PAS plugins are
all in PAS itself, and the "normal" one for the registry is in
PluginRegsitry.


Tres.
- --
===================================================================
Tres Seaver          +1 540-429-0999          tseaver at palladion.com
Palladion Software   "Excellence by Design"    http://palladion.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.2 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFFh/08+gerLs4ltQ4RArcGAJsFB1lw68LOoDvhcdiPkEOo0PgEtACdH2Qr
KZ2HXRssxqNTMTEoEnzBE4s=
=nGAk
-----END PGP SIGNATURE-----



More information about the Zope-PAS mailing list