Ejemplo n.º 1
0
def createComponentRegistry(context):
    enableSite(context, iface=IObjectManagerSite)

    components = PersistentComponents()
    components.__bases__ = (base,)
    components.__parent__ = aq_base(context)
    context.setSiteManager(components)
Ejemplo n.º 2
0
def enableZope3Site(context):
    portal = getToolByName(context, 'portal_url').getPortalObject()
    if not ISite.providedBy(portal):
        make_objectmanager_site(portal)
        logger.info('Made the portal a Zope3 site.')
    try:
        components = portal.getSiteManager()
    except ComponentLookupError:
        next = find_next_sitemanager(portal)
        if next is None:
            next = base
        name = '/'.join(portal.getPhysicalPath())
        components = PersistentComponents(name, (next,))
        components.__parent__ = portal
        portal.setSiteManager(components)
        logger.info("Site manager '%s' added." % name)
    else:
        if components.utilities.LookupClass != FiveVerifyingAdapterLookup:
            # for CMF 2.1 beta instances
            components.__parent__ = portal
            components.utilities.LookupClass = FiveVerifyingAdapterLookup
            components.utilities._createLookup()
            components.utilities.__parent__ = components
            logger.info('LookupClass replaced.')
    # Make sure to set the new site as the new active one
    setSite(portal)
Ejemplo n.º 3
0
def enableZope3Site(context):
    portal = getToolByName(context, 'portal_url').getPortalObject()
    if not ISite.providedBy(portal):
        make_objectmanager_site(portal)
        logger.info('Made the portal a Zope3 site.')
    try:
        components = portal.getSiteManager()
    except ComponentLookupError:
        next = find_next_sitemanager(portal)
        if next is None:
            next = base
        name = '/'.join(portal.getPhysicalPath())
        components = PersistentComponents(name, (next,))
        components.__parent__ = portal
        portal.setSiteManager(components)
        logger.info("Site manager '%s' added." % name)
    else:
        if components.utilities.LookupClass != FiveVerifyingAdapterLookup:
            # for CMF 2.1 beta instances
            components.__parent__ = portal
            components.utilities.LookupClass = FiveVerifyingAdapterLookup
            components.utilities._createLookup()
            components.utilities.__parent__ = components
            logger.info('LookupClass replaced.')
    # Make sure to set the new site as the new active one
    setSite(portal)
Ejemplo n.º 4
0
def createComponentRegistry(context):
    enableSite(context, iface=IObjectManagerSite)

    components = PersistentComponents()
    components.__bases__ = (base, )
    components.__parent__ = aq_base(context)
    context.setSiteManager(components)
Ejemplo n.º 5
0
def createComponentRegistry(context):
    enableSite(context, iface=IObjectManagerSite)

    components = PersistentComponents('++etc++site')
    components.__bases__ = (base, )
    components.__parent__ = aq_base(context)
    # Make sure calls to getSiteManager on me return myself
    # necessary because OFS.ObjectManager.getSiteManager expects _components
    components._components = components
    context.setSiteManager(components)
Ejemplo n.º 6
0
def createComponentRegistry(context):
    enableSite(context, iface=IObjectManagerSite)

    components = PersistentComponents('++etc++site')
    components.__bases__ = (base,)
    components.__parent__ = aq_base(context)
    # Make sure calls to getSiteManager on me return myself
    # necessary because OFS.ObjectManager.getSiteManager expects _components
    components._components = components
    context.setSiteManager(components)
Ejemplo n.º 7
0
Archivo: to21.py Proyecto: goschtl/zope
def add_root_site_manager(tool):
    """2.0.x to 2.1.0 upgrade step handler
    """
    logger = logging.getLogger('GenericSetup.upgrade')
    portal = aq_base(aq_parent(aq_inner(tool)))
    next = find_next_sitemanager(portal)
    if next is None:
        next = base
    name = '/'.join(portal.getPhysicalPath())
    components = PersistentComponents(name, (next,))
    components.__parent__ = portal
    portal.setSiteManager(components)
    logger.info("Site manager '%s' added." % name)
    getMultiAdapter((components, SetupEnviron()), IBody).body = _XML
    logger.info('Utility registrations added.')
Ejemplo n.º 8
0
def add_root_site_manager(tool):
    """2.0.x to 2.1.0 upgrade step handler
    """
    logger = logging.getLogger('GenericSetup.upgrade')
    portal = aq_base(aq_parent(aq_inner(tool)))
    next = find_next_sitemanager(portal)
    if next is None:
        next = base
    name = '/'.join(portal.getPhysicalPath())
    components = PersistentComponents(name, (next, ))
    components.__parent__ = portal
    portal.setSiteManager(components)
    logger.info("Site manager '%s' added." % name)
    getMultiAdapter((components, SetupEnviron()), IBody).body = _XML
    logger.info('Utility registrations added.')
Ejemplo n.º 9
0
def upgrade_root_site_manager(tool):
    """2.0.x to 2.1.0 upgrade step handler
    """
    logger = logging.getLogger('GenericSetup.upgrade')
    portal = aq_parent(aq_inner(tool))
    try:
        setSite(portal)
        sm = portal.getSiteManager()
        if sm.utilities.LookupClass != FiveVerifyingAdapterLookup:
            sm.__parent__ = aq_base(portal)
            sm.utilities.LookupClass = FiveVerifyingAdapterLookup
            sm.utilities._createLookup()
            sm.utilities.__parent__ = sm
            logger.info('LookupClass replaced.')
        else:
            for tool_interface in _BAD_UTILITIES:
                try:
                    iface = resolve(tool_interface)
                except ImportError:
                    continue

                if sm.queryUtility(iface) is not None:
                    sm.unregisterUtility(provided=iface)
                    logger.info('Unregistered utility for %s' % tool_interface)

            for tool_id, tool_interface in _TOOL_UTILITIES:
                tool_obj = getToolByName(portal, tool_id, default=None)
                try:
                    iface = resolve(tool_interface)
                except ImportError:
                    continue

                if tool_obj is not None and sm.queryUtility(iface) is None:
                    sm.registerUtility(tool_obj, iface)
                    logger.info('Registered %s for interface %s' % (
                                                      tool_id, tool_interface))
            return
    except ComponentLookupError:
        next = find_next_sitemanager(portal)
        if next is None:
            next = base
        name = '/'.join(portal.getPhysicalPath())
        sm = PersistentComponents(name, (next,))
        sm.__parent__ = aq_base(portal)
        portal.setSiteManager(sm)
        logger.info("Site manager '%s' added." % name)
    getMultiAdapter((sm, SetupEnviron()), IBody).body = _COMPONENTS_XML
    logger.info('Utility registrations added.')
Ejemplo n.º 10
0
def upgrade_root_site_manager(tool):
    """2.0.x to 2.1.0 upgrade step handler
    """
    logger = logging.getLogger('GenericSetup.upgrade')
    portal = aq_parent(aq_inner(tool))
    try:
        setSite(portal)
        sm = portal.getSiteManager()
        if sm.utilities.LookupClass != FiveVerifyingAdapterLookup:
            sm.__parent__ = aq_base(portal)
            sm.utilities.LookupClass = FiveVerifyingAdapterLookup
            sm.utilities._createLookup()
            sm.utilities.__parent__ = sm
            logger.info('LookupClass replaced.')
        else:
            for tool_interface in _BAD_UTILITIES:
                try:
                    iface = resolve(tool_interface)
                except ImportError:
                    continue

                if sm.queryUtility(iface) is not None:
                    sm.unregisterUtility(provided=iface)
                    logger.info('Unregistered utility for %s' % tool_interface)

            for tool_id, tool_interface in _TOOL_UTILITIES:
                tool_obj = getToolByName(portal, tool_id, default=None)
                try:
                    iface = resolve(tool_interface)
                except ImportError:
                    continue

                if tool_obj is not None and sm.queryUtility(iface) is None:
                    sm.registerUtility(tool_obj, iface)
                    logger.info('Registered %s for interface %s' %
                                (tool_id, tool_interface))
            return
    except ComponentLookupError:
        next = find_next_sitemanager(portal)
        if next is None:
            next = base
        name = '/'.join(portal.getPhysicalPath())
        sm = PersistentComponents(name, (next, ))
        sm.__parent__ = aq_base(portal)
        portal.setSiteManager(sm)
        logger.info("Site manager '%s' added." % name)
    getMultiAdapter((sm, SetupEnviron()), IBody).body = _COMPONENTS_XML
    logger.info('Utility registrations added.')
Ejemplo n.º 11
0
def make_site(obj, iface=ISite):
    """Give the specified object required qualities to identify it as a proper
    ISite.
    """
    if ISite.providedBy(obj):
        raise ValueError('This is already a site')

    next = find_next_sitemanager(obj)
    if next is None:
        next = base

    enableSite(obj, iface=iface)

    components = PersistentComponents('++etc++site', bases=(next, ))
    obj.setSiteManager(components)
    components.__parent__ = aq_base(obj)
Ejemplo n.º 12
0
def make_site(obj, iface=ISite):
    """Give the specified object required qualities to identify it as a proper
    ISite.
    """
    if ISite.providedBy(obj):
        raise ValueError('This is already a site')

    next = find_next_sitemanager(obj)
    if next is None:
        next = base

    enableSite(obj, iface=iface)

    components = PersistentComponents('++etc++site', bases=(next,))
    obj.setSiteManager(components)
    components.__parent__ = aq_base(obj)
Ejemplo n.º 13
0
 def getSiteManager(self):
     if self._components is None:
         next = find_next_sitemanager(self)
         if next is None:
             next = base
         name = '/'.join(self.getPhysicalPath())
         self._components = PersistentComponents(name, (next, ))
     return self._components
Ejemplo n.º 14
0
def make_site(obj, iface=ISite):
    """Give the specified object required qualities to identify it as a proper
    ISite.
    """
    if ISite.providedBy(obj):
        raise ValueError('This is already a site')
    
    next = find_next_sitemanager(obj)
    if next is None:
        next = base

    enableSite(obj, iface=iface)

    name = 'five'
    path = getattr(obj, 'getPhysicalPath', None)
    if path is not None and callable(path):
        name = '/'.join(path())

    components = PersistentComponents(name=name, bases=(next,))
    obj.setSiteManager(components)
    components.__parent__ = aq_base(obj)
Ejemplo n.º 15
0
 def getSiteManager(self):
     if self._components is None:
         # BBB: for CMF 2.0 instances
         next = find_next_sitemanager(self)
         if next is None:
             next = base
         name = '/'.join(self.getPhysicalPath())
         self._components = components = PersistentComponents(name, (next,))
         components.__parent__ = self
     elif self._components.utilities.LookupClass \
             != FiveVerifyingAdapterLookup:
         # BBB: for CMF 2.1 beta instances
         # XXX: should be removed again after the CMF 2.1 beta2 release
         self._components.utilities.LookupClass \
                 = FiveVerifyingAdapterLookup
         self._components.utilities._createLookup()
         self._components.utilities.__parent__ = self._components
         self._components.__parent__ = self
     return self._components
Ejemplo n.º 16
0
 def __init__(self, id, title='', description=''):
     super(PortalObjectBase, self).__init__(id, title, description)
     components = PersistentComponents('++etc++site')
     components.__parent__ = self
     self.setSiteManager(components)
Ejemplo n.º 17
0
 def __init__(self, id, title='', description=''):
     super(PortalObjectBase, self).__init__(id, title, description)
     components = PersistentComponents('++etc++site')
     components.__parent__ = self
     self.setSiteManager(components)