[Zope-CMF] GenericSetup and PluggableAuthService
Jens Vagelpohl
jens at dataflake.org
Thu Dec 31 07:00:23 EST 2009
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hanno Schlichting wrote:
> 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
This works like a treat and I used it for import and export. Afterwards
I needed to adjust the component import/export test harness a lttle bit
so the call to "site.getSiteManager" would not blow up because the site
in those tests is a PersistentComponents instance itself.
Now I can use all functions in the ZMI, including snapshots, for a
PluggableAuthService.
jens
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.8 (Darwin)
iEYEARECAAYFAks8klcACgkQRAx5nvEhZLIoggCgsa4dX3RxALxrC6TpHfm1pPsx
bUUAniHJlrSWNMMleUb2ShDzvRFVWESD
=UWLN
-----END PGP SIGNATURE-----
More information about the Zope-CMF
mailing list