Hash: SHA1

Hanno Schlichting wrote:
> On Wed, Dec 30, 2009 at 4:19 PM, Jens Vagelpohl <j...@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 Seaver          +1 540-429-0999          tsea...@palladion.com
Palladion Software   "Excellence by Design"    http://palladion.com
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org


Zope-CMF maillist  -  Zope-CMF@zope.org

See https://bugs.launchpad.net/zope-cmf/ for bug reports and feature requests

Reply via email to