'Move the page in the tree if necessary and save every placeholder
Content object.'

def save_model(self, request, obj, form, change):

    from cms.extensions import extension_pool
    target = request.GET.get('target', None)
    position = request.GET.get('position', None)
    new = False
    if (not obj.pk):
        new = True
    obj.save()
    if ((target is not None) and (position is not None)):
        try:
            target = self.model.objects.get(pk=target)
        except self.model.DoesNotExist:
            pass
        else:
            if ((position == 'last-child') or (position == 'first-child')):
                obj.parent_id = target.pk
            else:
                obj.parent_id = target.parent_id
            obj.save()
            obj = obj.move(target, pos=position)
    page_type_id = form.cleaned_data.get('page_type')
    copy_target_id = request.GET.get('copy_target')
    copy_target = None
    if (copy_target_id or page_type_id):
        if page_type_id:
            copy_target_id = page_type_id
        copy_target = self.model.objects.get(pk=copy_target_id)
        if (not page_permissions.user_can_view_page(request.user, page=copy_target)):
            raise PermissionDenied()
        obj = obj.reload()
        copy_target._copy_attributes(obj, clean=True)
        obj.save()
        for lang in copy_target.get_languages():
            copy_target._copy_contents(obj, lang)
    if ('permission' not in request.path_info):
        language = form.cleaned_data['language']
        Title.objects.set_or_create(request, obj, form, language)
    if copy_target:
        extension_pool.copy_extensions(copy_target, obj)
    if (new and (Page.objects.filter(site_id=obj.site_id).count() == 1)):
        obj.publish(language)
