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)
def createComponentRegistry(context): enableSite(context, iface=IObjectManagerSite) components = PersistentComponents() components.__bases__ = (base, ) components.__parent__ = aq_base(context) context.setSiteManager(components)
def createComponentRegistry(context): enableSite(context, iface=IObjectManagerSite) components = PersistentComponents() components.__bases__ = (base,) components.__parent__ = aq_base(context) context.setSiteManager(components)
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)
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)
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.')
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.')
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.')
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.')
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)
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)
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)
def __init__(self, id, title='', description=''): super(PortalObjectBase, self).__init__(id, title, description) components = PersistentComponents('++etc++site') components.__parent__ = self self.setSiteManager(components)