Friday, March 27, 2009

How to set a ReferenceField programmatically

I'm creating a method for importing content into Plone. The content types that are created have a reference field on them, but how to set that from your import method (or import script)?

A ReferenceField simply stores the UID of the referenced object, so you can do it like this (if your field is called myReference:

Wednesday, March 11, 2009

Installing deliverance

Following the steps on the deliverance site didn't work for me: I get stuff like /usr/bin/ld: i386 architecture of input file ... is incompatible with i386:x86-64 output I'm guessing it's because i'm on a 64 bit platform, and the build doesn't take this into account. If you are on a 32 bit platform, the steps on the deliverance site may be easier for you.

To circumvent it, i installed deliverance from svn, using these steps:

# Get development libraries (i'm on Ubuntu)
sudo apt-get install libxml2-dev libxslt-dev
# Create virtualenv
virtualenv --no-site-packages deliverance_svn
cd deliverance_svn
# Install latest version of setuptools to prevent error "global name 'log' is not defined"
. bin/activate
easy_install -U setuptools
# Checkout deliverance from svn
sudo apt-get install subversion
svn co deliverance
cd deliverance
# Install deliverance
../bin/python install
# Install paster in virtualenv
../bin/easy_install PasteScript
cd ..
# Create deliverance instance
./bin/paster create -t deliverance DelivTest
# Answer the questions...
./bin/deliverance-proxy DelivTest/etc/deliverance.xml

Monday, March 9, 2009

Dit en dat

Soms is het leven mooi. Bijvoorbeeld wanneer iemand deze voorbeeldtekst aanlevert:

"Ik heb veel ervaring met dit en dat, maar mijn echte specialiteit is zus en zo. Dus daarom juist nu meteen en ondanks alles, zou ik willen zeggen, evenwel nochtans, desalniettemin."

Het heeft iets weg van Ajuinen & Look, had ook iets van Koot & Bie kunnen zijn, of Maar een snelle Google levert niets op, dus voorlopig schrijf ik 'm toe aan Philip Smits.

Monday, March 2, 2009

xml.parsers.expat.ExpatError when running ArchGenXML

I got this error:

$ ~/bin/archgenxml-virtualenv/bin/archgenxml uml/OPSB.uml
xml.parsers.expat.ExpatError: not well-formed (invalid token): line 51, column 0

For a more complete stacktrace see
Turns out it's a bug in ArgoUML 0.28 BETA 2: When saving as a .uml file, a sequence of "^@"'s is inserted. Remove it manually, or use 0.26 for now.

See for the bug report.

The folks at Tigris were quick to follow this up. They've targeted it for the next beta release (0.28 beta 3).
another edit:
Beta 3 is out, this bug is fixed.

ArchGenXml: How to get the latest profile.xmi?

Use the agx_argouml_profile script that came with your version of ArchGenXML.

$ cd ~/bin
$ virtualenv archgenxml-latest
$ cd archgenxml-latest
$ . bin/activate
$ easy_install archgenxml
$ ./bin/agx_argouml_profile
$ ls
archgenxml_profile.xmi bin include lib
$ deactivate