예제 #1
0
    def _replaceBaseline( self, baseline ):
        # move the working copy object to the baseline, returns the
        # new baseline
        baseline_id = baseline.getId()

        # delete the baseline from the folder to make room for the
        # committed working copy
        baseline_container = aq_parent( aq_inner( baseline ) )
        baseline_container._delOb( baseline_id )

        # delete the working copy from the its container
        wc_container = aq_parent( aq_inner( self.context ) )

        # trick out the at machinery to not delete references
        self.context._v_cp_refs = 1
        self.context._v_is_cp = 0

        wc_container.manage_delObjects( [self.context.getId()] )

        # move the working copy back to the baseline container
        working_copy = aq_base( self.context )
        working_copy.setId( baseline_id )
        baseline_container._setOb( baseline_id, working_copy )

        new_baseline = baseline_container._getOb( baseline_id )

        # reregister our references with the reference machinery after moving
        Referenceable.manage_afterAdd( new_baseline, new_baseline,
                                       baseline_container)

        return new_baseline
예제 #2
0
    def _replaceBaseline(self, baseline):
        # move the working copy object to the baseline, returns the
        # new baseline
        baseline_id = baseline.getId()

        # delete the baseline from the folder to make room for the
        # committed working copy
        baseline_container = aq_parent(aq_inner(baseline))
        # Check if we are a default_page, because this property of the
        # container might get lost.
        is_default_page = (
            baseline_container.getProperty('default_page', '') == baseline_id)
        baseline_pos = baseline_container.getObjectPosition(baseline_id)
        baseline_container._delOb(baseline_id)

        # uninedxing the deleted baseline object from portal_catalog
        portal_catalog = getToolByName(self.context, 'portal_catalog')
        portal_catalog.unindexObject(baseline)

        # delete the working copy from the its container
        wc_container = aq_parent(aq_inner(self.context))

        # trick out the at machinery to not delete references
        self.context._v_cp_refs = 1
        self.context._v_is_cp = 0

        wc_id = self.context.getId()
        # Bypass AT security check,
        # checking `iterate : Check in content` should be sufficient
        with util.adopt_system():
            wc_container.manage_delObjects([wc_id])

        # move the working copy back to the baseline container
        working_copy = aq_base(self.context)
        working_copy.setId(baseline_id)
        baseline_container._setOb(baseline_id, working_copy)
        baseline_container.moveObjectToPosition(baseline_id, baseline_pos)

        new_baseline = baseline_container._getOb(baseline_id)
        if is_default_page:
            # Restore default_page to container.  Note that the property might
            # have been removed by an event handler in the mean time.
            if baseline_container.hasProperty('default_page'):
                baseline_container._updateProperty('default_page', baseline_id)
            else:
                baseline_container._setProperty('default_page', baseline_id)

        # reregister our references with the reference machinery after moving
        Referenceable.manage_afterAdd(new_baseline, new_baseline,
                                      baseline_container)

        notify(ObjectMovedEvent(new_baseline, wc_container,
                                wc_id, baseline_container, baseline_id))

        return new_baseline
예제 #3
0
    def _replaceBaseline(self, baseline):
        # move the working copy object to the baseline, returns the
        # new baseline
        baseline_id = baseline.getId()

        # delete the baseline from the folder to make room for the
        # committed working copy
        baseline_container = aq_parent(aq_inner(baseline))
        # Check if we are a default_page, because this property of the
        # container might get lost.
        is_default_page = (
            baseline_container.getProperty('default_page', '') == baseline_id)
        baseline_pos = baseline_container.getObjectPosition(baseline_id)
        baseline_container._delOb(baseline_id)

        # uninedxing the deleted baseline object from portal_catalog
        portal_catalog = getToolByName(self.context, 'portal_catalog')
        portal_catalog.unindexObject(baseline)

        # delete the working copy from the its container
        wc_container = aq_parent(aq_inner(self.context))

        # trick out the at machinery to not delete references
        self.context._v_cp_refs = 1
        self.context._v_is_cp = 0

        wc_id = self.context.getId()
        wc_container.manage_delObjects([wc_id])

        # move the working copy back to the baseline container
        working_copy = aq_base(self.context)
        working_copy.setId(baseline_id)
        baseline_container._setOb(baseline_id, working_copy)
        baseline_container.moveObjectToPosition(baseline_id, baseline_pos)

        new_baseline = baseline_container._getOb(baseline_id)
        if is_default_page:
            # Restore default_page to container.  Note that the property might
            # have been removed by an event handler in the mean time.
            if baseline_container.hasProperty('default_page'):
                baseline_container._updateProperty('default_page', baseline_id)
            else:
                baseline_container._setProperty('default_page', baseline_id)

        # reregister our references with the reference machinery after moving
        Referenceable.manage_afterAdd(new_baseline, new_baseline,
                                      baseline_container)

        notify(ObjectMovedEvent(new_baseline, wc_container,
                                wc_id, baseline_container, baseline_id))

        return new_baseline
예제 #4
0
 def migrate_references(self):
     """Migrate references annotation."""
     # Restor the references annotation
     if hasattr(self, REFERENCE_ANNOTATION):
         at_references = getattr(self, REFERENCE_ANNOTATION)
         setattr(self.new, REFERENCE_ANNOTATION, at_references)
     # Run the reference manage_afterAdd to transition all copied
     # references
     is_cp = getattr(self.old, '_v_is_cp', _marker)
     self.new._v_is_cp = 0
     Referenceable.manage_afterAdd(self.new, self.new, self.new.__parent__)
     if is_cp is not _marker:
         self.new._v_is_cp = is_cp
     else:
         del self.new._v_is_cp
예제 #5
0
 def migrate_references(self):
     """Migrate references annotation."""
     # Restor the references annotation
     if hasattr(self, REFERENCE_ANNOTATION):
         at_references = getattr(self, REFERENCE_ANNOTATION)
         setattr(self.new, REFERENCE_ANNOTATION, at_references)
     # Run the reference manage_afterAdd to transition all copied
     # references
     is_cp = getattr(self.old, "_v_is_cp", _marker)
     self.new._v_is_cp = 0
     Referenceable.manage_afterAdd(self.new, self.new, self.new.__parent__)
     if is_cp is not _marker:
         self.new._v_is_cp = is_cp
     else:
         del self.new._v_is_cp
예제 #6
0
    def _replaceBaseline(self, baseline):
        # move the working copy object to the baseline, returns the new
        # baseline

        # First, copy children of baseline to the working copy
        for key in baseline.keys():
            sub_ob = baseline[key]
            baseline._delObject(key, suppress_events=True)
            # use _get_id to handle naming in case of conflicts
            new_id = self.context._get_id(key)
            self.context._setObject(new_id, sub_ob, suppress_events=True)

        # delete the baseline from the folder to make room for the committed
        # working copy
        baseline_id = baseline.getId()
        baseline_container = aq_parent(aq_inner(baseline))
        baseline_container._delOb(baseline_id)

        # delete the working copy from the its container
        wc_container = aq_parent(aq_inner(self.context))

        # trick out the at machinery to not delete references
        self.context._v_cp_refs = 1
        self.context._v_is_cp = 0

        wc_id = self.context.getId()
        wc_container._delObject(wc_id)

        # move the working copy back to the baseline container
        working_copy = aq_base(self.context)
        working_copy.setId(baseline_id)
        baseline_container._setOb(baseline_id, working_copy)

        new_baseline = baseline_container._getOb(baseline_id)

        # reregister our references with the reference machinery after moving
        Referenceable.manage_afterAdd(
            new_baseline, new_baseline, baseline_container)

        notify(ObjectMovedEvent(
            new_baseline, wc_container,
            wc_id, baseline_container, baseline_id))
        return new_baseline
예제 #7
0
    def _replaceBaseline(self, baseline):
        # move the working copy object to the baseline, returns the new
        # baseline

        # First, copy children of baseline to the working copy
        for key in baseline.keys():
            sub_ob = baseline[key]
            baseline._delObject(key, suppress_events=True)
            # use _get_id to handle naming in case of conflicts
            new_id = self.context._get_id(key)
            self.context._setObject(new_id, sub_ob, suppress_events=True)

        # delete the baseline from the folder to make room for the committed
        # working copy
        baseline_id = baseline.getId()
        baseline_container = aq_parent(aq_inner(baseline))
        baseline_container._delOb(baseline_id)

        # delete the working copy from the its container
        wc_container = aq_parent(aq_inner(self.context))

        # trick out the at machinery to not delete references
        self.context._v_cp_refs = 1
        self.context._v_is_cp = 0

        wc_id = self.context.getId()
        wc_container._delObject(wc_id)

        # move the working copy back to the baseline container
        working_copy = aq_base(self.context)
        working_copy.setId(baseline_id)
        baseline_container._setOb(baseline_id, working_copy)

        new_baseline = baseline_container._getOb(baseline_id)

        # reregister our references with the reference machinery after moving
        Referenceable.manage_afterAdd(new_baseline, new_baseline,
                                      baseline_container)

        notify(
            ObjectMovedEvent(new_baseline, wc_container, wc_id,
                             baseline_container, baseline_id))
        return new_baseline
예제 #8
0
    def _replaceBaseline(self, baseline):
        # move the working copy object to the baseline, returns the
        # new baseline
        baseline_id = baseline.getId()

        # delete the baseline from the folder to make room for the
        # committed working copy
        baseline_container = aq_parent(aq_inner(baseline))
        baseline_pos = baseline_container.getObjectPosition(baseline_id)
        baseline_container._delOb(baseline_id)

        # uninedxing the deleted baseline object from portal_catalog
        portal_catalog = getToolByName(self.context, 'portal_catalog')
        portal_catalog.unindexObject(baseline)

        # delete the working copy from the its container
        wc_container = aq_parent(aq_inner(self.context))

        # trick out the at machinery to not delete references
        self.context._v_cp_refs = 1
        self.context._v_is_cp = 0

        wc_id = self.context.getId()
        wc_container.manage_delObjects([wc_id])

        # move the working copy back to the baseline container
        working_copy = aq_base(self.context)
        working_copy.setId(baseline_id)
        baseline_container._setOb(baseline_id, working_copy)
        baseline_container.moveObjectToPosition(baseline_id, baseline_pos)

        new_baseline = baseline_container._getOb(baseline_id)

        # reregister our references with the reference machinery after moving
        Referenceable.manage_afterAdd(new_baseline, new_baseline,
                                      baseline_container)

        notify(
            ObjectMovedEvent(new_baseline, wc_container, wc_id,
                             baseline_container, baseline_id))

        return new_baseline
예제 #9
0
    def _replaceBaseline( self, baseline ):
        # move the working copy object to the baseline, returns the
        # new baseline
        baseline_id = baseline.getId()

        # delete the baseline from the folder to make room for the
        # committed working copy
        baseline_container = aq_parent( aq_inner( baseline ) )
        baseline_pos = baseline_container.getObjectPosition(baseline_id)
        baseline_container._delOb( baseline_id )

        # uninedxing the deleted baseline object from portal_catalog
        portal_catalog = getToolByName(self.context, 'portal_catalog')
        portal_catalog.unindexObject(baseline)

        # delete the working copy from the its container
        wc_container = aq_parent( aq_inner( self.context ) )

        # trick out the at machinery to not delete references
        self.context._v_cp_refs = 1
        self.context._v_is_cp = 0

        wc_id = self.context.getId()
        wc_container.manage_delObjects([wc_id])

        # move the working copy back to the baseline container
        working_copy = aq_base( self.context )
        working_copy.setId( baseline_id )
        baseline_container._setOb( baseline_id, working_copy )
        baseline_container.moveObjectToPosition(baseline_id, baseline_pos)

        new_baseline = baseline_container._getOb( baseline_id )

        # reregister our references with the reference machinery after moving
        Referenceable.manage_afterAdd( new_baseline, new_baseline,
                                       baseline_container)

        notify(ObjectMovedEvent(new_baseline, wc_container,
                                wc_id, baseline_container, baseline_id))

        return new_baseline