Development Environment

Installing the Virtualenv Environment

As it is explained in Deployment Environment, it is best practice to install PubliForge into a “virtual” Python environment. To do so, invoke the following:

$ virtualenv ~/bin/virtualenv
$ source ~/bin/virtualenv/bin/activate
(virtualenv3)$ pip install -U pip setuptools

Setting up an UTF-8 environment

To efficiently work with text data, you must have an UTF-8 environment. To check it, run the locale program:

$ locale

If you don’t have .UTF-8 in your configuration, make sure that on your system an UTF-8 locale is generated. To do so, type:

$ sudo dpkg-reconfigure locales

Then, in your ~/.bashrc file, add lines similar to:

$ export LC_ALL=en_US.UTF-8
$ export LANG=en_US.UTF-8
$ export LANGUAGE=en_US.UTF-8

To make these changes active in the current shell, source the .bashrc:

$ source ~/.bashrc

All newly started interactive bash processes will respect these settings.

Installing Required Packages and modules

See Installing Required Packages for packages to install.

If you want to use the automatic HTML validation, you need to install the wdg-html-validator package.

Setting up the Database

See Setting up the Database to setup your database.

For development, you can name your database PubliForge:

$ sudo su - postgres -c "createdb -T template0 -E UTF-8 -O publiforge PubliForge"

Installing PubliForge

Check out the latest code:

$ source ~/bin/virtualenv/bin/activate
(virtualenv)$ pip install Mercurial
(virtualenv)$ hg clone https://hg.publiforge.org/PubliForge

Install application and its dependencies:

(virtualenv)$ cd PubliForge
(virtualenv)$ pip install -e .

Now, set up the application by tuning development.ini and agent_development.ini (See Customization with INI File).

Populating the Database and the Storages

You need to use the pfpopulate console script to populate your database and your storages. To do so, type the following command:

(virtualenv)$ pfpopulate development.ini

Testing the application

To get this functionality working, you’ll need to install nose package:

(virtualenv)$ pip install nose

Once nose is installed, you can run the tests:

(virtualenv)$ nosetests -v --with-id --failed

Running the application

Finally, to launch your application in front mode, invoke the following:

(virtualenv)$ pserve --reload development.ini

To simulate an agent only mode, open a second console and execute:

$ source ~/bin/virtualenv/bin/activate
(virtualenv)$ pserve --reload development_agent.ini

The running application will now be available at http://localhost:6543.