コード例 #1
0
    def evolve(self, context, generation):
        name = "%s.evolve%d" % (self.package_name, generation)

        evolver = __import__(name, {}, {}, ["*"])

        root = getRootFolder(context)
        for site in findObjectsProviding(root, ifaces.IMainApp):
            setSite(site)
            evolver.evolve(site)
        transaction.commit()
コード例 #2
0
def evolve(context):
    """Evolve the ZODB from a Zope 3.1 to a 3.2 compatible format.

    - Converts all internal principals to use new password managers.
    """
    root = getRootFolder(context)

    for site in findObjectsProviding(root, ISite):
        sm = site.getSiteManager()
        for principal in findObjectsProviding(sm, IInternalPrincipal):
            if not hasattr(principal, "_passwordManagerName"):
                principal._passwordManagerName = "Plain Text"
            if not hasattr(principal, "_password"):
                principal._password = principal.__dict__["password"]
                del principal.__dict__["password"]
コード例 #3
0
def evolve(context):
    root = getRootFolder(context)
    for obj in findObjectsProviding(root, IAnnotatable):
        dc = IWriteZopeDublinCore(obj)
        if isinstance(dc, ZDCAnnotatableAdapter):
            # simply mark the ZDCAnnotationData object as dirty so
            # that it gets repickled
            dc._mapping._p_activate()
            dc._mapping._p_changed = True

            # also mark the object holding a reference to it (the
            # annotations mapping) as dirty.  It contains a reference
            # to the old class path for ghosts
            annotations = IAnnotations(obj)
            if DCkey in annotations:
                annotations[DCkey] = annotations[DCkey]
コード例 #4
0
def evolve(context):
    root = getRootFolder(context)
    for site in findObjectsProviding(root, ifaces.IMainApp):
        evolve_site(site)
コード例 #5
0
def evolve(context):
    """Evolve existing PAUs and group folders.

    - Group folders should no longer be registered.

    - PAUs that use group folders should use their contents name, not their
      (formerly) registered name.

    Group folders used by multiple PAUs were not supported, and are not
    supported with this evolution.
    """
    root = getRootFolder(context)

    for site in findObjectsProviding(root, ISite):
        sm = site.getSiteManager()
        for pau in findObjectsProviding(
            sm, zope.app.authentication.interfaces.IPluggableAuthentication):
            for nm, util in getUtilitiesFor(
                zope.app.authentication.interfaces.IAuthenticatorPlugin,
                context=pau):
                if groupfolder.IGroupFolder.providedBy(util):
                    if util.__parent__ is not pau:
                        raise RuntimeError(
                            "I don't know how to migrate your database: "
                            "each group folder should only be within the "
                            "Pluggable Authentication utility that uses it")
                    # we need to remove this registration
                    regs = [r for r in sm.registeredUtilities()
                            if r.component == util]
                    if len(regs) != 1:
                        raise RuntimeError(
                            "I don't know how to migrate your database: "
                            "you should only have registered your group "
                            "folder as an IAuthenticatorPlugin, but it looks "
                            "like it's registered for something additional "
                            "that I don't expect")
                    r = regs[0]
                    sm.unregisterUtility(
                       util,
                       zope.app.authentication.interfaces.IAuthenticatorPlugin,
                       nm)
                    if r.name in pau.authenticatorPlugins:
                        if util.__name__ != r.name: # else no-op
                            plugins = list(pau.authenticatorPlugins)
                            if util.__name__ in pau.authenticatorPlugins:
                                # argh! another active plugin's name is
                                # the same as this group folder's
                                # __name__.  That means we need to choose
                                # a new name that is also not in
                                # authenticatorPlugins and not in
                                # pau.keys()...
                                ct = 0
                                nm = '%s_%d' % (util.__name__, ct)
                                while (nm in pau.authenticatorPlugins or
                                       nm in pau):
                                    ct += 1
                                    nm = '%s_%d' % (util.__name__, ct)
                                IObjectMover(util).moveTo(pau, nm)
                            plugins[plugins.index(r.name)] = util.__name__
                            pau.authenticatorPlugins = tuple(plugins)
            for k, r in pau.registrationManager.items():
                if groupfolder.IGroupFolder.providedBy(r.component):
                    del pau.registrationManager[k]
コード例 #6
0
 def install(self, context):
     root = getRootFolder(context)
     zope.event.notify(grok.events.DatabaseCreatedEvent(root))