Importing and exporting Plone folders using quintagroup.transmogrify

0. Exporting single folder only

Here is explained how to export and import Plone CMS folders between different Plonen versions, or different CMS systems, using XML based content marshalling and quintagroup.transmogrifier.

This overcomes some problems with Zope management based export/import which uses Python pickles and thus needs identical codebase on the source and target site. Exporting and importing between Plone 3 and Plone 4 is possible.

You can limit export to cover source content to with arbitary portal_catalog conditions. If you limit source content by path you can effectively export single folder only.

The recipe described here assumes the exported and imported site have the same path for the folder. Manually rename or move the folder on source or target to change its location.

Note: The instructions here requires quintagroup.transmogrify version 0.4 or later … or trunk version during the writing of this blog post.

1) Source site

Execute these actions on the source Plone site.

Install quintagroup.transmogrifier via buildout and Plone add-on control panel.

Go to Site setup > Content migration.

Edit export settings. Remove unnecessary pipeline entries by looking the example below. Add a new catalogsource blueprin. The exclude-contained option makes sure we do not export unnecessary items from the parent folderst:

.

[transmogrifier]
pipeline =
    catalogsource
    fileexporter
    marshaller
    datacorrector
    writer
    EXPORTING

[catalogsource]
blueprint = quintagroup.transmogrifier.catalogsource
path = query= /isleofback/ohjeet
exclude-contained = true

Also we need to include some field-level exluding bits for the folders, because the target site does not necessary have the same content types available as the source site and this may prevent setting up folderish content settings:

[marshaller]
blueprint = quintagroup.transmogrifier.marshaller
exclude =
  immediatelyAddableTypes
  locallyAllowedTypes

You might want to remove other, unneeded blueprints from the export pipeline. For example, portletexporter may cause problems if the source and target site do not have the same portlet code.

Go to Zope Management Interface > portal_setup > Export tab. Check Content (transmogrifier) step. Press Export Selected Steps at the bottom of the page. Now a .tar.gz file will be downloaded.

During the export process instance.log file is updated with status info. You might want to follow it in real-time from UNIX command line

tail -f var/log/instance.log

In log you should see entries running like:

2010-12-27 12:05:30 INFO EXPORTING _path=sisalto/ohjeet/yritys/yritysten-tuotetiedot/tuotekortti
2010-12-27 12:05:30 INFO EXPORTING
Pipeline processing time: 00:00:02
          94 items were generated in source sections
          94 went through full pipeline
           0 were discarded in some section

2) Target site

Execute these actions on the target Plone site.

Install quintagroup.transmogrifier via buildout and Plone add-on control panel.

Open target site instance.log file for monitoring the import process

tail -f var/log/instance.log

Go to Zope Management Interface > portal_setup > Import tab.

Choose downloaded setup_toolxxx.tar.gz file at the bottom of the page, for Import uploaded tarball input.

Run import and monitoring log file for possible errors. Note that the import completes even if the target site would not able to process incoming content. If there is a serious problem the import seems to complete succesfully, but no content is created.

Note: Currently export/import is not perfect. For example, ZMI content type icons are currently lost in the process. It is recommended to do a test run on a staging server before doing this process on a production server. Also, the item order in the folder is being lost.

\"\" Subscribe to RSS feed Follow me on Twitter Follow me on Facebook Follow me Google+

Local XAMPP development and UNIX file permissions

If you are using XAMPP Apache+MySQL+PHP stack to develop web applications on your OSX or Linux computer you might want to fiddle with Apache settings to make your life easier.

By default XAMPP users nobody user for running Apache. If you try to load any file created by your normal system user Apache will give access denied error. This means that either you must make all PHP files readable for everyone, or change the file owner. This is painful if you need to repeat the process for every file.

Instead, it is easier to make XAMPP run under the permissions of your local user.

Edit /Applications/XAMPP/etc/httpd.conf:

<IfModule !mpm_winnt_module>
<IfModule !mpm_netware_module>
User yourusername
Group staff
</IfModule>
</IfModule>
<IfModule !mpm_winnt_module><IfModule !mpm_netware_module>
DocumentRoot "/Users/yourusername/yoursiteroot"

You also need to change the location of setting default folder execution rights htdocs location to your development location

#
# This has been changed from /Applications/XAMPP/htdocs
#
<Directory "/Users/moo/code/joomla/mobilejoomla_dev">
    Options Indexes FollowSymLinks ExecCGI Includes
   AllowOverride All
</Directory>

And now Apache will happily eat all files you create or edit.

\"\" Subscribe to RSS feed Follow me on Twitter Follow me on Facebook Follow me Google+

Enhanced Apache logging: request duration, balancer member, transferred bytes

This helps you to diagnose problems on the production environment if you are running Apache or Apache mod_balancer. Put to your <virtualhost>

# timestamp referer useragent, server time seconds/microseconds, transfered bytes input/output, which balancer was used
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" duration:%T/%D io:%I/%O balancer:%{BALANCER_WORKER_NAME}e"
TransferLog     /var/log/apache2/yoursite.log
More info

\"\" Subscribe to RSS feed Follow me on Twitter Follow me on Facebook Follow me Google+

My ZSH prompt and configuration for OSX and Ubuntu Linux

ZSH is a shell replacement for advanced command line users, featuring command autocompletion and such. ZSH works across OSX, BSD and Linux operating systems.

Below is my .zshrc configuration file I use on OSX. It is based on Phil!’s ZSH prompt. It sets up nice colored prompt, colours for ls and some aliases. For OSX, get ZSH from Macports. Any suggestions welcome – please comment.

# This is a modified version of Phil's prompt
# I removed the battery monitor, color and simplified
# the title bar to just the host
#
# Changes by calvinhp
#
# Changes by moo
#
# http://aperiodic.net/phil/prompt/

function precmd {
    local TERMWIDTH
    (( TERMWIDTH = ${COLUMNS} - 1 ))

    # Truncate the path if it's too long.
    PR_FILLBAR=""
    PR_PWDLEN=""

    local promptsize=${#${(%):---%D{%a\,%b %d}-----}}
    local pwdsize=${#${(%):-%d}}

    if [[ "$promptsize + $pwdsize" -gt $TERMWIDTH ]]; then
            ((PR_PWDLEN=$TERMWIDTH - $promptsize))
    else
        PR_FILLBAR="\${(l.(($TERMWIDTH - ($promptsize + $pwdsize)))..${PR_HBAR}.)}"
    fi

    # Only show user in the prompt if it isn't yourself
    # Make sure and set the $ME var in .zshrc
    PR_IMPOSTER=""
    [ "$ME" != "" ] && [ $(whoami) != "$ME" ] && PR_IMPOSTER="(%n%)"

    PR_PROJECT=""
    local THIRD_DIR=$(pwd | cut -f 4,5 -d /)
    if [ "$THIRD_DIR" = "sixfeetup/projects" ]; then
        PR_PROJECT="$(pwd | cut -f 6 -d /)"
        [ ! "$PR_PROJECT" = "" ] && PR_PROJECT="($PR_PROJECT)"
    fi
}

setopt extended_glob
preexec () {
    if [[ "$TERM" == "screen" ]]; then
        local CMD=${1[(wr)^(*=*|sudo|-*)]}
        echo -n "\ek$CMD\e\\"
    fi
}

setprompt () {
    # Need this so the prompt will work.
    setopt prompt_subst

 	autoload colors zsh/terminfo
    if [[ "$terminfo[colors]" -ge 8 ]]; then
		colors
    fi
    for color in RED GREEN YELLOW BLUE MAGENTA CYAN WHITE; do
        eval PR_$color='%{$terminfo[bold]$fg[${(L)color}]%}'
        eval PR_LIGHT_$color='%{$fg[${(L)color}]%}'
        (( count = $count + 1 ))
    done
    PR_NO_COLOUR="%{$terminfo[sgr0]%}"

    # See if we can use extended characters to look nicer.
    typeset -A altchar
    set -A altchar ${(s..)terminfo[acsc]}
    PR_SET_CHARSET="%{$terminfo[enacs]%}"
    PR_SHIFT_IN="%{$terminfo[smacs]%}"
    PR_SHIFT_OUT="%{$terminfo[rmacs]%}"
    PR_HBAR=${altchar[q]:--}
    PR_ULCORNER=${altchar[l]:--}
    PR_LLCORNER=${altchar[m]:--}
    PR_LRCORNER=${altchar[j]:--}
    PR_URCORNER=${altchar[k]:--}

    # Decide if we need to set titlebar text.
    case $TERM in
       xterm*)
           PR_TITLEBAR=$'%{\e]0;%m $PR_IMPOSTER $PR_PROJECT\a%}'
           ;;
       screen)
           PR_TITLEBAR=$'%{\e_screen \005 (\005t) | %m $PR_IMPOSTER\e\\%}'
           ;;
       *)
           PR_TITLEBAR=''
           ;;
    esac

    # Decide whether to set a screen title
    if [[ "$TERM" == "screen" ]]; then
        PR_STITLE=$'%{\ekzsh\e\\%}'
    else
        PR_STITLE=''
    fi

    # Finally, the prompt (removed the color - claytron)
    PROMPT='$PR_SET_CHARSET$PR_STITLE${(e)PR_TITLEBAR}\
$PR_CYAN$PR_SHIFT_IN$PR_ULCORNER$PR_BLUE$PR_HBAR$PR_SHIFT_OUT(\
$PR_MAGENTA%$PR_PWDLEN<...<%~%<<$PR_BLUE)($PR_MAGENTA%(!.%SROOT%s.%n)$PR_GREEN\
$PR_BLUE)$PR_SHIFT_IN$PR_HBAR$PR_CYAN$PR_HBAR${(e)PR_FILLBAR}$PR_BLUE$PR_HBAR$PR_SHIFT_OUT(\
$PR_MAGENTA@%m:%l\
$PR_BLUE)$PR_SHIFT_IN$PR_HBAR$PR_CYAN$PR_URCORNER$PR_SHIFT_OUT\

$PR_CYAN$PR_SHIFT_IN$PR_LLCORNER$PR_BLUE$PR_HBAR$PR_SHIFT_OUT(\
%(?..$PR_LIGHT_RED%?$PR_BLUE:)\
${(e)PR_APM}$PR_YELLOW%D{%H:%M}\
$PR_LIGHT_BLUE:%(!.$PR_RED.$PR_WHITE)%#$PR_BLUE)$PR_SHIFT_IN$PR_HBAR$PR_SHIFT_OUT\
$PR_CYAN$PR_SHIFT_IN$PR_HBAR$PR_SHIFT_OUT\
$PR_NO_COLOUR '
}

setprompt

export PATH=/opt/local/bin:/opt/local/sbin:$PATH

# For OSX users, alias nano to real editor
alias nano="open -a Smultron"

export CLICOLOR=1

# enable ls colors by default - use yellow for directories
LS_COLORS="no=00:fi=00:di=01;34:ln=01;36:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:su=37;41:sg=30;43:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.svgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.lzma=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.bz2=01;31:*.bz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.rar=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:"

\"\" Subscribe to RSS feed Follow me on Twitter Follow me on Facebook Follow me Google+