|Version 4 (modified by dmartinc, 3 years ago) (diff)|
This section's aim is to log some tricks and caveats that you should take into consideration while developing for Indico.
Therefore, if you add a new .js file, remember to add the corresponding line to the proper .cfg file in etc/js (usually indico.cfg).
2. Usage of .getUser() within a management area
Don't assume that a user is always logged in just because he is in the management area of an event. getUser() can return None because the user could have used a modification key to login. So, always check that getUser() is not None.
3. Do not use Python built-ins as variable names
This is more a general Python programming tip, but most people fall into it some time or another.
Try not to use Python built-in keywords, such as "type", "list", "dict", "vars", etc. as variable names.
Example of problem:
def mymethod(self, value, type): self._type = type ... if type(value) is int: #we try to use Python's built-in type function to check the type of an object ...
This will fail because we have redefined type when using it as a function argument; so the built-in "type" function is no longer available.
Using PyLint helps detect these problems.
4. Use the right i18n (internationalization) function
var today = '<%=_("Today") %>';
will become, when rendered in English:
var today = 'Today';
But when rendered in French, it will become:
var today = 'Aujourd'hui';
This will provoke a syntax error because the string was using single quotes (').
Therefore, the correct thing to do is:
var today = $T("Today");