[Zope-CMF] GenericSetup and PluggableAuthService

Tres Seaver tseaver at palladion.com
Wed Dec 30 17:41:14 EST 2009


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

Hanno Schlichting wrote:
> On Wed, Dec 30, 2009 at 4:19 PM, Jens Vagelpohl <jens at dataflake.org> wrote:
>> In the debugger I see that the object in question is a absolute_url
>> adapter residing in the base component registry in the site root. IMHO
>> the components exporter should not look at the base registry at all,
>> only a local registry if one exists in the folder the tool sits in. Correct?
> 
> Right. As you noticed nobody ever tried to use GS outside a CMF/Plone context :)

Not quite:  I have made heavy use of it for migrating PAS configurations
separately from any other site config.

> The code in question does a:
> 
> sm = getSiteManager(context.getSite())
> 
> That will get the nearest site manager, which in case of CMF will
> always be the one in the CMF site root.
> 
> What you want is probably something like this:
> 
> from zope.component.interfaces import ComponentLookupError
> from zope.component.interfaces import IComponentRegistry
> from zope.location.interfaces import IPossibleSite
> 
> def importComponentRegistry(context):
>     """Import local components.
>     """
>     # context is the portal_setup tool
>     # getSite is GS API to get the parent
>     site = context.getSite()
>     sm = None
>     if IPossibleSite.providedBy(site):
>         # All object managers are an IPossibleSite, but this
>         # defines the getSiteManager method to be available
>         try:
>             sm = site.getSiteManager()
>         except ComponentLookupError:
>             sm = None
> 
>     if sm is None or not IComponentRegistry.providedBy(sm):
>         logger = context.getLogger('componentregistry')
>         logger.info("Can not register components, as no registry was found.")
>         return
> 
>     importer = queryMultiAdapter((sm, context), IBody)
>     if importer:
>         body = context.readDataFile('componentregistry.xml')
>         if body is not None:
>             importer.body = body
> 
> 
> And then adjust exportComponentRegistry in a similar way. This is
> untested code :)

Why would a PAS plugin do such a thing?  PAS doesn't expect (or want)
any local / persistent component registry.  This issue (steps showing up
in inappropriate profiles) was the reason for the step registries being
part of a profile, and why I argued (unsuccessfully) against their
deprecation way back when:  I would have preferred fixing whatever
issues existesd, over using a "global" stop registry.



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.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAks71woACgkQ+gerLs4ltQ529ACgwT7S2I7gAeb69hFOqjhTDxNP
IMwAniF83Usoz4CPoFX/37/nsOUT+wr1
=Ni96
-----END PGP SIGNATURE-----



More information about the Zope-CMF mailing list