Sektionen
Benutzerspezifische Werkzeuge
Sie sind hier: Startseite Support Dokumentation docs Plone Referenzen exportieren/importieren

Plone Referenzen exportieren/importieren

Da beim umbenennen/verschieben vom Plone Root die Referenzen verloren gehen, sollte man diese vorher exportieren und danach wieder herstellen.

import transaction
import sys
from Testing.makerequest import makerequest
from Products.contentmigration.archetypes import InplaceATItemMigrator
from AccessControl.SecurityManagement import newSecurityManager
from Products.CMFPlone.utils import getToolByName

from Products.PloneArticle.interfaces import IImageInnerContentProxy

PORTAL_NAME = 'plone'
admin_user = 'admin'
OUTPUT = open('references.txt','w')

app = makerequest(app)
newSecurityManager(None,app.acl_users.getUserById(admin_user))
site = app[PORTAL_NAME]

# exports all existing references to a CSV file
rc = getToolByName(site,'reference_catalog')

for b in rc():
    print >>OUTPUT, b.sourceUID, b.targetUID, b.relationship

transaction.commit()

 

import transaction
import sys
from Testing.makerequest import makerequest
from Products.contentmigration.archetypes import InplaceATItemMigrator
from AccessControl.SecurityManagement import newSecurityManager
from Products.CMFPlone.utils import getToolByName
from Products.Archetypes.ReferenceEngine import ContentReferenceCreator

from Products.PloneArticle.interfaces import IImageInnerContentProxy

PORTAL_NAME = 'renamedplone'
admin_user = 'admin'
INPUT = open('references.txt','r')

app = makerequest(app)
newSecurityManager(None,app.acl_users.getUserById(admin_user))
site = app[PORTAL_NAME]

#exports all existing references to a CSV file

rc = getToolByName(site,'reference_catalog')

for line in INPUT:
    source, target, relationship = line.split()
    print "addind ref %s -> %s (%s)" % (source, target, relationship)
    rc.addReference(source, target, relationship)

transaction.commit()