psj.policy Installation
***********************

How to install psj.policy inside another package
================================================

To install psj.policy into the global Python environment (or a virtualenv),
using a traditional Zope 2 instance, you can do this:

 * When you're reading this you have probably already run
   ``easy_install psj.policy``. Find out how to install setuptools
   (and EasyInstall) here:
   http://peak.telecommunity.com/DevCenter/EasyInstall

 * If you are using Zope 2.9 (not 2.10), get `pythonproducts`_ and install it
   via::

       python setup.py install --home /path/to/instance

   into your Zope instance.

 * Create a file called ``psj.policy-configure.zcml`` in the
   ``/path/to/instance/etc/package-includes`` directory.  The file
   should only contain this::

       <include package="psj.policy" />

.. _pythonproducts: http://plone.org/products/pythonproducts


Alternatively, if you are using zc.buildout and the plone.recipe.zope2instance
recipe to manage your project, you can do this:

 * Add ``psj.policy`` to the list of eggs to install, e.g.:

    [buildout]
    ...
    eggs =
        ...
        psj.policy

  * Tell the plone.recipe.zope2instance recipe to install a ZCML slug:

    [instance]
    recipe = plone.recipe.zope2instance
    ...
    zcml =
        psj.policy

  * Re-run buildout, e.g. with:

    $ ./bin/buildout

You can skip the ZCML slug if you are going to explicitly include the package
from another package's configure.zcml file.

Note, that the real installation is quite cumbersome, because it is
based on the collaboration with OpenOffice.org. See below to see, how
you can install psj.policy in detail.


Installing psj.policy via ``buildout``
======================================

We describe an installation on a freshly installed Ubuntu
system. Windows(TM) systems are not supported by time of writing
this.

1) Install the base system.

  We are using Ubuntu 10.04 server LTS here. This means less stuff on
  your machine. The whole system described below will need less than
  2.5 GB disk space.

  Make sure you choose `English (US)` as base system. Otherwise you
  will have to tweak the tests lateron. This is caused by OOos
  'intelligent' locale detection, which produces different documents
  depending on your system locale. The tests here rely on the US
  locale. (XXX: this might be a lie meanwhile).

  Afterwards setup ``/etc/apt/sources.list`` so, that universe and
  multiverse repositories are included.

  Then, as superuser, run::

     # apt-get update

  to fetch the list of the newly added repositories.

  During base install we created a user `zope`.

2) Install additional packages:

  We need Python2.7. On our system this is the default version.  So we
  can try to do::

     # apt-get install python2.7-dev

  to get the headers for building Zope.

  Then, as superuser, do::

     # apt-get install subversion rpm unzip gcc libc6-dev \
                       libxslt1.1 libxslt1-dev xsltproc \
                       libsm6 sun-java5-bin \
                       libjpeg62 libjpeg62-dev libfreetype6 \
                       libfreetype6-dev tidy \
                       xvfb python2.7-profiler

  These are the generally needed packages for building and running
  ``psj.policy``. The latter package (``python2.7-profiler``) is not
  needed, if you installed from sources. Some of the packages may be
  already installed on your system. Concerning the Java package (above
  Sun Java 1.5 is installed) you might get along with a different one.

  The `tidy` package is needed for postprocessing of HTML docs.

  The libsm6 and xvfb packages are needed for the X-server
  requirements of OOo. You don't have to run a X-server with this
  installation, not even a framebuffer server, but some libs are
  nonetheless needed by OOo to start. The xvfb package includes all
  this packages, so it's easier to include it.

  If you already have a running X-server on your system, then you
  don't have to install libsm6 nor xvfb.

  The profiler is needed only, if you want to run the tests, which is
  warmly recommended.

  We also install::

     # apt-get install openssh-server

  to be able access the machine remotely.


3) Fetch, build and install ``psj.policy``

  Now it's time to get the real code. As a normal user do::

     $ git clone https://github.com/ulif/psj.policy

  This should populate your directory with a new subdir
  ``psj.policy``. Now change to it and run the bootstrapper::

     $ cd psj.policy
     $ python2.7 bootstrap/bootstrap.py

  This will create the ``buildout`` script and some subdirs. Run the
  buildout script::

     $ ./bin/buildout

4) Start the OOo server

  Now we should be able to start the OOo server::

     $ ./bin/oooctl start


5) Test the code

  Run::

     $ ./bin/instance test -s psj.policy
