Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
251 lines (156 sloc) 7.91 KB

Paylogic Codereview

Paylogic Codereview allows you to run Rietveld - the code review tool available at However, it's a highly customized version of Rietveld. It contains several useful additions, bugfixes as well.

If you want to use it, please read the documentation below.

Custom features implemented

  • Creation or update of the codereview issue using the remote repositories automatically, parameters are taken from given Fogbugz case
  • Approve patchset for further merging, implemented also through the integration with Fogbugz
  • Improved django admin to simplify user management and other administrative tasks
  • Fogbugz authentication integrated
  • Bugfixes related to deployment on local server, not Google App Engine
  • Main functionality covered with tests

Development Environment

To set up the development environment, run:

# install system dependencies, requires sudo access!
make dependencies

# install python dependencies, initialize configs
make develop

Then, to run the codereview server:

env/bin/python runserver

Open a browser, go to and you can use the codereview tool.

You'll need to grant some permissions for your user(s) authenticated through fogbugz:

  • codereview.add_issue - create issue
  • codereview.view_issue - view issue
  • codereview.change_comment - change comment
  • codereview.add_comment - add comment
  • codereview.approve_patchset - approve patchset (by Gatekeepers)

Production Deployment

make build index_url=<pypi index containing custom package versions>

This command will make ./build folder containing all needed to run the application.

Several python dependencies are for now released only to our corporate pypi index, which is not public. However, the code of those version is absolutely public, because it's just forks & fixes. Here is the list of repository locations:

Until we'll make public corporate pypi server, you can make your own releases or just install them in editable mode

The preferred method to deploy Django applications is to use WSGI supporting web server. Use build/ file as WSGI script.

There is one important thing to remember. Django serves media (static) files only in development mode. For running Rietveld in a production environment, you need to setup your web-server to serve the /static/ alias directly from the ./build/static_build folder.

There is the example configuration for running Rietveld with Apache2+mod_wsgi Feel free to copy it from apache.conf.example. You may need to change 'codereview' user name in WSGI directives and adjust paths to match your installation.

When running in a production environment, keep in Django's CSRF protection is disabled in this example!

Using wheels

To speedup the build process, 2 make targets are implemented:

make wheel
Build wheels for all python dependencies, storing them in the cache directory
make upload-wheel (depends on make wheel)

Upload previously generated wheels to given private devpi server.


  • devpi_url - devpi server URL to use
  • devpi_path - index path to upload to
  • devpi_login - login to use for devpi authorization
  • devpi_password - password to use for devpi authorization

After you'll upload wheels, make build and make develop time will be dramatically reduced, if you will pass index_url parameter pointing to the same devpi server index you used for make upload-wheel, for example:

make build index_url=

Be aware that binary wheels can only be used on exactly same architecture and environment as they were built.

Creating the local environment

In order to create new issues - with patches, descriptions and so on - you need to create the local environment.

First of all, you need to create a local settings file. This can be done by copying example one:

cp paylogic/ paylogic/

The most important settings are:

see django documentation about it
dictionary of vcs-specific settings, folder prefix, regular expression of the branch definition, etc, see config for an example
prefix to try to add to feature branch value taken from fogbugz case field, allows to shorten feature branch definition
prefix to try to add to feature branch value taken from fogbugz case field, allows to shorten feature branch definition
temporary folder used to clone and export repositories
URL of your fogbugz instance
URL of your fogbugz instance
Fogbugz user API token to be used for Fogbugz API calls
authorization token for few paylogic custom API methods exposed by codereview
Fogbugz user ID. Used to assign an approved codereview's case to
Fogbugz field id to get and set approved revision information on the case
Fogbugz field id to set target branch value. Used for mergekeepering process
Fogbugz field id to get original branch URL to create or update codereview issue
Fogbugz field id to get feature branch URL to create or update codereview issue
Fogbugz field id to get CI project field values. Used for mergekeepering process
Fogbugz case tag to set when the case is approved by the gatekeeper
List of files to ignore when creating or updating the codereview issue
Maximum file size over which file will be consirered as blob, so it's text will not be shown as review context, only download will be possible
List of functions, which will be executed to check if generated diff is valid. Functions should receive single string argument - full diff.
Function to get autompletion list for the target branch field in the gatekeeper approval form. Prototype is (ci_project, original_branch, target_branch, branches)

For the defaults of the listed settings, see paylogic/

Paylogic notes

Paylogic customizations are mostly located in paylogic folder. However, we also had to change some parts of codereview package.

Database migrations

It's problematic to use automatic database migrations tools as codereview app uses google app engine models. Here is the simple but working solution we've made:

cat paylogic/migrations/*.sql | ./ dbshell

SQL scripts in paylogic/migrations folder are named in order so this way we ensure the correct order of migrations. Idempotency is ensured by using IF NOT EXISTS or similar inside of SQL scripts.

Adding Users

Go to /admin URL and login as a super user. Users may change password by going to /admin/password_change URL.


This software is licensed under the Apache 2 license

© 2014 Paylogic International.