2013-02-24 22:04:55 +01:00
|
|
|
Development of Debian Member Portfolio Service
|
|
|
|
==============================================
|
|
|
|
|
|
|
|
The Debian Member Portfolio Service is implemented in `Python
|
2014-10-14 13:38:29 +02:00
|
|
|
<https://www.python.org>`_ using the `Pylons
|
|
|
|
<https://pylons.readthedocs.org/en/latest/>`_ web application
|
2013-02-24 22:04:55 +01:00
|
|
|
framework.
|
|
|
|
|
|
|
|
The following sections describe how to setup a local development environment
|
|
|
|
for the Debian Member Portfolio Service.
|
|
|
|
|
|
|
|
All instructions assume that you work on a Debian system. You should use Python
|
|
|
|
2.7 for development.
|
|
|
|
|
|
|
|
Setup of a local development
|
|
|
|
----------------------------
|
|
|
|
|
|
|
|
To start working on the source code you need to have `git`_ installed::
|
|
|
|
|
|
|
|
sudo aptitude install git
|
|
|
|
|
|
|
|
.. _git: http://www.git-scm.com/
|
|
|
|
|
|
|
|
The canonical git repository for the Debian Member Portfolio Service is
|
2014-02-08 23:54:51 +01:00
|
|
|
available at http://debianstuff.dittberner.info/git/debianmemberportfolio.git.
|
|
|
|
To get a clone of the source code you change to a directory of your choice and
|
2013-02-24 22:04:55 +01:00
|
|
|
invoke git clone::
|
|
|
|
|
|
|
|
cd ~/src
|
2014-02-08 23:54:51 +01:00
|
|
|
git clone http://debianstuff.dittberner.info/git/debianmemberportfolio.git
|
2013-02-24 22:04:55 +01:00
|
|
|
|
|
|
|
You should use `virtualenv`_ to separate the development environment from your
|
|
|
|
system wide Python installation. You can install virtualenv using::
|
|
|
|
|
|
|
|
sudo aptitude install python-virtualenv
|
|
|
|
|
|
|
|
.. _virtualenv: https://pypi.python.org/pypi/virtualenv
|
|
|
|
|
|
|
|
When you have :command:`virtualenv` installed you should create a virtual
|
|
|
|
environment for Debian Member Portfolio Service development and install the
|
|
|
|
requirements using `pip <https://pypi.python.org/pypi/pip>`_::
|
|
|
|
|
|
|
|
mkdir ~/.virtualenvs
|
|
|
|
virtualenv --distribute ~/.virtualenvs/dmportfolio
|
|
|
|
. ~/.virtualenvs/dmportfolio/bin/activate
|
2014-02-08 23:54:51 +01:00
|
|
|
cd ~/src/debianmemberportfolio
|
2015-02-20 22:19:07 +01:00
|
|
|
pip install -r jessiereq.pip
|
2013-02-24 22:04:55 +01:00
|
|
|
|
|
|
|
.. note::
|
|
|
|
|
|
|
|
The Debian Member Portfolio Service instance at http://portfolio.debian.net/
|
2015-02-20 22:19:07 +01:00
|
|
|
is running on a Debian Jessie server, therefore :file:`jessiereq.pip`
|
2013-02-24 22:04:55 +01:00
|
|
|
contains dependency versions matching that Debian release.
|
|
|
|
|
|
|
|
The dependency download and installation into the virtual environment takes
|
|
|
|
some time.
|
|
|
|
|
|
|
|
After you have your virtual environment ready you need to setup the project for
|
|
|
|
development::
|
|
|
|
|
|
|
|
python setup.py develop
|
|
|
|
|
|
|
|
Debian Member Portfolio Service needs the JQuery JavaScript library to function
|
|
|
|
properly. The JQuery library is not included in the git clone and must be
|
|
|
|
copied into the subdirectory
|
2014-02-08 23:54:51 +01:00
|
|
|
:file:`debianmemberportfolio/public/javascript/jquery`. On Debian systems you
|
|
|
|
can install the package libjs-jquery and place a symlink to the directory
|
|
|
|
:file:`/usr/share/javascript` into :file:`debianmemberportfolio/public`: ::
|
2013-02-24 22:04:55 +01:00
|
|
|
|
|
|
|
sudo aptitude install libjs-jquery
|
2014-02-08 23:54:51 +01:00
|
|
|
ln -s /usr/share/javascript debianmemberportfolio/public
|
2013-02-24 22:04:55 +01:00
|
|
|
|
|
|
|
Prepare for first startup
|
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
|
|
|
|
The Debian Member Portfolio Service uses data from the Debian keyring to get
|
|
|
|
information regarding PGP keys and names related to email addresses. Before you
|
|
|
|
can run the service you need to fetch a copy of the keyring and prepare it for
|
|
|
|
use by the code.
|
|
|
|
|
|
|
|
.. note::
|
|
|
|
|
|
|
|
You need rsync and gnupg for these tasks::
|
|
|
|
|
|
|
|
sudo aptitude install rsync gnupg
|
|
|
|
|
|
|
|
When you have both installed you can run::
|
|
|
|
|
|
|
|
. ~/.virtualenvs/dmportfolio/bin/activate
|
|
|
|
./synckeyrings.sh
|
2014-02-08 23:54:51 +01:00
|
|
|
python debianmemberportfolio/model/keyringanalyzer.py
|
2013-02-24 22:04:55 +01:00
|
|
|
|
|
|
|
The first synchronizes the keyrings in :file:`$HOME/debian/keyring.debian.org`
|
|
|
|
with files on the `keyring.debian.org <http://keyring.debian.org>`_ host. And
|
|
|
|
the second generates a key/value database in
|
2014-02-08 23:54:51 +01:00
|
|
|
:file:`debianmemberportfolio/model/keyringcache` that is used by the code.
|
2013-02-24 22:04:55 +01:00
|
|
|
|
|
|
|
Run a development server
|
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
|
|
|
|
Pylons uses PasteScript to run a development server. You can run a development
|
|
|
|
server using::
|
|
|
|
|
|
|
|
paster serve --reload development.ini
|
|
|
|
|
|
|
|
The output of this command should look like the following::
|
|
|
|
|
|
|
|
Starting subprocess with file monitor
|
|
|
|
Starting server in PID 31377.
|
|
|
|
serving on http://127.0.0.1:5000
|
|
|
|
|
|
|
|
You can now access your development server at the URL that is printed by the command.
|
|
|
|
|
|
|
|
If you want to stop the development server press :kbd:`Ctrl + C`.
|
|
|
|
|
|
|
|
Common development tasks
|
|
|
|
------------------------
|
|
|
|
|
|
|
|
Add new URL
|
|
|
|
~~~~~~~~~~~
|
2013-02-24 22:52:36 +01:00
|
|
|
|
|
|
|
Debian Member Portfolio Service uses a ini style configuration file
|
2014-02-08 23:54:51 +01:00
|
|
|
:file:`debianmemberportfolio/model/portfolio.ini` to configure the generated URL
|
2013-02-24 22:52:36 +01:00
|
|
|
patterns. The actual URL generation is done in
|
2014-02-08 23:54:51 +01:00
|
|
|
:py:class:`~debianmemberportfolio.controllers.portfolio.DdportfolioController`
|
2013-02-24 22:52:36 +01:00
|
|
|
in the
|
2014-02-08 23:54:51 +01:00
|
|
|
:py:meth:`~debianmemberportfolio.controllers.portfolio.DdportfolioController.urllist`
|
2013-02-24 22:52:36 +01:00
|
|
|
method.
|
|
|
|
|
|
|
|
If you want to add a new URL type you have to add a line in
|
2014-02-08 23:54:51 +01:00
|
|
|
:file:`portfolio.ini` and an entry in
|
|
|
|
:py:class:`~debianmemberportfolio.controllers.portfolio.DdportfolioController`'s
|
|
|
|
:py:attr:`~debianmemberportfolio.controllers.portfolio.DdportfolioController._LABELS`
|
2013-02-24 22:52:36 +01:00
|
|
|
dictionary. The top level dictionary keys correspond to sections in the ini
|
|
|
|
file. The dictionary values are dictionaries themselves that contain a special
|
|
|
|
key ``label`` that defines the label of the section in the output and keys for
|
|
|
|
each entry to be rendered in that section. The values in these sub-dictionaries
|
|
|
|
are strings marked for translation using the :py:func:`~pylons.i18n._` function from
|
|
|
|
:py:mod:`pylons.i18n`.
|
|
|
|
|
2014-02-08 23:54:51 +01:00
|
|
|
The patterns in :file:`portfolio.ini` can contain the following placeholders
|
2013-02-24 22:52:36 +01:00
|
|
|
that are filled at runtime:
|
|
|
|
|
|
|
|
================== ========================================
|
|
|
|
Placeholder Replacement
|
|
|
|
================== ========================================
|
|
|
|
%(aliothusername)s user name on `alioth.debian.org`_
|
|
|
|
%(email)s email address (URL encoded)
|
|
|
|
%(emailnoq)s email address
|
|
|
|
%(firstchar)s first character of the email address
|
|
|
|
%(forumsid)d forum user id
|
|
|
|
%(gpgfp)s GNUPG/PGP key fingerprint
|
|
|
|
%(name)s full name (i.e. John Smith)
|
|
|
|
%(username)s Debian user name
|
|
|
|
%(wikihomepage)s full name in camel case (i.e. JohnSmith)
|
|
|
|
================== ========================================
|
|
|
|
|
2014-10-14 13:38:29 +02:00
|
|
|
.. _alioth.debian.org: https://alioth.debian.org/
|
2013-02-24 22:52:36 +01:00
|
|
|
|
|
|
|
The replacement of placeholders is performed in the
|
2014-02-08 23:54:51 +01:00
|
|
|
:py:meth:`~debianmemberportfolio.controllers.portfolio.DdportfolioController.urllist`
|
2013-02-24 22:52:36 +01:00
|
|
|
method. And uses data from the Debian keyring. Access to the pre-parsed keyring
|
|
|
|
data is performed using the
|
2014-02-08 23:54:51 +01:00
|
|
|
:py:func:`~debianmemberportfolio.model.dddatabuilder.build_data` function of
|
|
|
|
the module :py:mod:`debianmemberportfolio.model.dddatabuilder`, which uses
|
|
|
|
several helper functions from :py:mod:`debianmemberportfolio.model.keyfinder`
|
|
|
|
to access the key information.
|