Quantcast
Channel: Planet Plone - Where Developers And Integrators Write
Viewing all articles
Browse latest Browse all 3535

UW Oshkosh How-To's: How to export/import portions of a Plone site

$
0
0

Some scenarios covered by this how-to:

  • you want to migrate a Plone 3.0 site to Plone 3.1 
  • you want to copy the contents of a folder from one Plone site to another Plone site

Things you will need:

  • Manager role on both sites (source and destination)
  • The destination site's Zope server has to have Products.QuickImporter installed.  Currently only the new campus skin server has this installed.

The Gist of the Process

Go to the Zope Management Interface (ZMI) for the source site.  For example if you are moving content from http://uwosh.edu/existing_site to http://plonedev.uwosh.edu/new_site, go to http://uwosh.edu/existing_site/manage.  You will need Manager role to do this.

Let's say you want to copy the contents of the folder "Documents".  

  • In the ZMI, locate the folder "Documents".  
  • Check the box next to it, then at the bottom of the page click on the Import/Export button.
  • In the upper portion of the page, select the "Download to local machine" option, then click the Export button.  Save the resulting Documents.zexp file anywhere you like on your computer.
  • Do the same for every other content item you want to export.

You now have a bunch of .zexp files on your computer.  Next, you must import them onto the new site.  Go to http://plonedev.uwosh.edu/new_site/manage (again you will need Manager role to do this):

  • In the ZMI, locate the Add button at the top right of the page.  Next to it is a drop down list of items you can add.  Choose "Quick Importer" in that drop down list, then click the Add button.  (Depending on your browser, you may not have to click on the Add button).
  • In the resulting form, click the Choose button and navigate to the .zexp file on your computer that you want to import, then click OK.
  • Back in the Quick Importer form, leave the "Take ownership of imported objects" option selected, and press the "Do Quick Import" button.
  • Do the same for every .zexp file you want to import.

The Lazy Way to Export These Items

At the root of your site in the ZMI, add a Script (Python) object using the drop down list at the top right of the page.  Call it something like ".exportSiteContent" (the period in the name makes it show up at the top of your site folder).  The body of the script should be as follows:

# When prompted, set the parameter download_locally to y or Y if you want the exported
# zexp files to be downloaded to your local computer.  BEWARE that exports 
# downloaded locally will require heavy memory use on the server.  Large exports
# should NEVER be downloaded locally.
#
# Any other value for the parameter download_locally will result in exported zexp
# files being left on the server, in the ZEO client's or instance's var directory, 
# e.g.. /opt/Plone-4.0.2-2/zeocluster/var/client3/blah.zexp

myId = script.getId()

boringStuff = ['CacheSetup_OFSCache', 'CacheSetup_PageCache',
               'CacheSetup_ResourceRegistryCache', 'HTTPCache',
               'MailHost', 'Members', 'RAMCache', 'ResourceRegistryCache',
               'acl_users', 'archetype_tool', 'caching_policy_manager',
               'content_type_registry', 'error_log', 'kupu_library_tool',
               'mimetypes_registry', 'plone_utils', 'portal_actionicons',
               'portal_actions', 'portal_archivist', 'portal_atct',
               'portal_cache_settings', 'portal_calendar', 'portal_catalog',
               'portal_controlpanel', 'portal_css', 'portal_diff',
               'portal_discussion', 'portal_factory',
               'portal_form_controller', 'portal_groupdata',
               'portal_groups', 'portal_historiesstorage',
               'portal_uidhandler', 'portal_interface',
               'portal_javascripts', 'portal_kss', 'portal_languages',
               'portal_memberdata', 'portal_membership', 'portal_metadata',
               'portal_migration', 'portal_modifier',
               'portal_password_reset', 'portal_properties',
               'portal_purgepolicy', 'portal_quickinstaller',
               'portal_referencefactories', 'portal_registration',
               'portal_repository', 'portal_setup', 'portal_skins',
               'portal_squid', 'portal_syndication', 'portal_transforms',
               'portal_types', 'portal_uidannotation',
               'portal_uidgenerator', 'portal_historyidhandler',
               'portal_undo', 'portal_url', 'portal_view_customizations',
               'portal_workflow', 'reference_catalog',
               'translation_service', 'uid_catalog', 'portal_tinymce', 
               'formgen_tool', 'portal_registry', ]

if download_locally == 'y' or download_locally == 'Y':
    print '<p>zexp files will be downloaded to your computer - beware of server memory use for large exports!</p>'
    download_str = '&download=True'
else:
    print '<p>zexp files will be created on the server, in a directory like /opt/Plone/zeocluster/var/client3/ </p>'
    download_str = ''

siteRoot = container
print '<p>Click on the following links to export each item:</p><ul>'
for itemTuple in siteRoot.items():
    (item, itemType) = itemTuple
    if item not in boringStuff and item not in myId:
        url = siteRoot.absolute_url() + '/manage_exportObject?id=%s%s' % (item, download_str)
        print '<li><a href="%s">%s</a></li>' % (url, item)

print "</ul>"
return printed

Copy and paste the above into the body of the script, replacing what was there.  Press the Save Changes button.

How to run the script

Warning: if you use this script to export big items (e.g. folders containing a lot of items) it will use a lot of memory on the server.  Run this script using only a non-public ZEO client (e.g. on one of our *082 ports).

To run the script, click on the Test tab at the top of the page.  The resulting page shows links, one per "interesting" content items in your site, that you can export and download to your computer (i.e. not saved on the server).  Click on each such link and save the .zexp file onto your computer.

How to handle News and Events

If you want to export and import the News and Events folders, you will have to do the following:

  • Export News and get a news.zexp.
  • Export Events and get a events.zexp.
  • On the destination site, go to portal_types -> Large Plone Folder, check the box next to "Implicitly addable?", press the Save Changes button.  If you don't do this, you won't be able to import News and Events (they are Large Folders).
  • In the ZMI, check the box next to News, then press the Rename button at bottom, rename to "news.orig".
  • Rename Events the same way to "events.orig".
  • Do the import using QuickImporter, as described above.
  • Go back to portal_types -> Large Plone Folder and uncheck the box for "Implicitly addable?", press Save Changes.

Here is the list of items you DO NOT need to export/import:

Although I describe the following as items you do not need to export, some of them may contain customizations that you would like to apply to your new site.  For example, portal_actions may contain custom site tabs, and if you have allowed Member folder creation then some of the Member folders may contain content created by your users.  Similarly, acl_users may contain local users you created.  

  • CacheSetup_OFSCache
  • CacheSetup_PageCache (Page Cache Manager)
  • CacheSetup_ResourceRegistryCache (Cache for saved ResourceRegistry files)
  • HTTPCache
  • MailHost
  • Members (Users) 
  • RAMCache
  • ResourceRegistryCache (Cache for saved ResourceRegistry files)
  • acl_users
  • archetype_tool
  • caching_policy_manager
  • content_type_registry
  • error_log
  • kupu_library_tool (Kupu visual editor)
  • mimetypes_registry (MIME types recognized by Plone)
  • plone_utils (Various utility methods)
  • portal_actionicons (Associates actions with icons)
  • portal_actions (Contains custom tabs and buttons)
  • portal_archivist
  • portal_atct (ATContentTypes Tool)
  • portal_cache_settings (Cache Configuration Tool) 
  • portal_calendar (Controls how events are shown)
  • portal_catalog (Indexes all content in the site)
  • portal_controlpanel (Control Panel)
  • portal_css (CSS Registry)
  • portal_diff
  • portal_discussion (Controls how discussions are stored)
  • portal_factory (Responsible for the creation of content objects)
  • portal_form_controller (Manages form validation and post-validation actions)
  • portal_groupdata (Handles properties on groups)
  • portal_groups (Handles group related functionality)
  • portal_historiesstorage
  • portal_uidhandler
  • portal_interface (Allows to query object interfaces)
  • portal_javascripts (JavaScript Registry)
  • portal_kss (KSS Registry)
  • portal_languages (Manages available languages)
  • portal_memberdata (Handles the available properties on members)
  • portal_membership (Handles membership policies)
  • portal_metadata (Controls metadata like keywords, copyrights, etc)
  • portal_migration (Upgrades to newer Plone versions)
  • portal_modifier
  • portal_password_reset
  • portal_properties (UW Oshkosh Sustainability)
  • portal_purgepolicy
  • portal_quickinstaller (Allows to install/uninstall products)
  • portal_referencefactories
  • portal_registration (Handles registration of new users)
  • portal_repository
  • portal_setup
  • portal_skins (Controls skin behaviour (search order etc))
  • portal_squid
  • portal_syndication (Generates RSS for folders)
  • portal_transforms (Handles data conversion between MIME types)
  • portal_types (Controls the available content types in your portal)
  • portal_uidannotation
  • portal_uidgenerator
  • portal_historyidhandler
  • portal_undo (Defines actions and functionality related to undo)
  • portal_url (Methods to anchor you to the root of your Plone site)
  • portal_view_customizations (Manages view customizations)
  • portal_workflow (Contains workflow definitions for your portal)
  • reference_catalog
  • translation_service (Provides access to the translation machinery)
  • uid_catalog
 

Viewing all articles
Browse latest Browse all 3535

Trending Articles