Hacking on JuliaBase

This unfinished chapter explains how to contribute to the JuliaBase project itself instead of adapting it to your institution.

Architecture

Since JuliaBase is based on the Django Web framework, it consists of several Django apps. The core app is called “jb_common”. It provides functionality which is essential for all JuliaBase components. On top of that, the app “samples” contains all features of a samples database. However, it does not contain institute-specific code in order to remain generic and flexible. This institute-specific code resides in an app of its own and must be created by a skilled programmer.

JuliaBase is shipped together with an example institute app called “inm”. It provides not only a demo for JuliaBase, it also is a good starting point for your own app. Besides, essential testing of JuliaBase can only be done on top of inm.

Coding guidelines

JuliaBase source code modules should not exceed 1000 lines of code. You should stick to PEP 8 and the Django coding guidelines. String literals are double-quoted unless double quotes appear in them:

"This is a string literal"
'This is "another" string literal'

Never use u in front of a string literal. Instead, JuliaBase code uses the unicode_literals future import.

JuliaBase makes one exception from PEP 8: It allows lines with 125 columns instead of only 80.

All variables and source code comments should be in English.

Note

I skip all docstrings in the code examples in this document because otherwise, the examples would be too bloated. However, write rich Docstrings for all non-trivial functions and methods. Write them in ReST format.

Internationalization is a very important point in JuliaBase. All strings exposed to the user should be marked as translatable by putting them in _("...") unless you have very good reason not to do so (e.g. for some proper names). Note that in code which is executed at module load time (e.g. model and form fields), _ should stand for gettext_lazy, whereas within functions and methods which are executed on each request, it should be gettext. You may achieve this by setting _ to gettext_lazy at the beginning of the module, and to gettext at the end.

Boilerplate code

Start every file with:

#!/usr/bin/env python3
#
# {Licence}

"""{Module docstring}
"""

{Python standard library imports}
{Non-standard imports (Numpy, Scipy, matplotlib etc)
{Django imports}
{JuliaBase imports}