Coding guidelines


All the code must follow PEP 8. You can use Flake8 to check for compliance. Flake8 is installed by default to all server environments, via MoPyTools.

Flake8 provides a Mercurial hook, to perform a code check on every commit or qrefresh. Here’s an example of Mercurial ~/.hgrc file:

commit =
qrefresh =

strict = 0

If strict option is set to 1, any warning will block the commit. When strict is set to 0, warnings are just displayed in the standard output.

Read these:

Unicode vs Str

All internal strings in our server applications must use the unicode type unless stated otherwise.

Exceptions are:

  • Rendered e-mails
  • LDAP or SQL specific values

When the str type is used, the utf-8 encoding must be used:

>>> uni = u'Café'
>>> uni
>>> uni.encode('utf-8')
>>> print uni.encode('utf-8')
>>> print uni

More on Unicode :