Monday, October 12, 2015¶
Courses in Chatelet¶
they cannot change the state of a course because it never imported any workflow. Fixed. Note that we don’t import the default workflow (
lino_xl.lib.courses.workflows) but define our own (in
lino_xl.lib.cal.mixins.Reservation.get_recurrence_set()method returned None when no room was specified. I removed this rule from the default implementation (i.e. it is okay to generate events and record presences even when no room is specified. The room of a course is not important in Chatelet.)
Course.suggest_cal_guestsmethod now works a bit differently and is more easy to adapt by overriding
Adapted and extended the test in
Nobel peace prize to Tunisia¶
I just read that the Tunisian national dialogue quartet wins 2015 Nobel peace prize. Lino can be proud to have its second core developer living in Tunisia.
Documenting plugins that are not installed¶
The link to
work. This was due to a old and fundamental documentation problem: The
API documentation is generated using Sphinx (more precisely the
autodoc and autosummary extensions). And a Sphinx documentation
tree is built in a single Python process. And Django does not
allow to have more than one
settings.py module within one
Python process. The docs for Lino Welfare are built using
lino_welfare.projects.std.settings.demo as settings (that’s
defined in the
docs/conf.py file). And the
lino_welfare.chatelet.lib.courses.models happens to
not be installed in that environment.
Sphinx doesn’t show the problem directly (it just says that it cannot import the module), but you can simulate what happens:
>>> import lino >>> lino.startup('lino_welfare.projects.std.settings.demo') >>> import lino_welfare.chatelet.lib.courses.models Traceback (most recent call last): ... File ".../lino_xl.lib.courses/models.py", line 270, in EventsByTeacher master = dd.plugins.courses.teacher_model AttributeError: 'Plugin' object has no attribute 'teacher_model'
This traceback came because the
courses plugins are not designed
to be used together. It is normal (in a Django context) that you get
problems when you try to import both of them. We can work around this
by providing fallback mechanisms like this one:
try: teacher_model = dd.plugins.courses.teacher_model pupil_model = dd.plugins.courses.pupil_model except AttributeError: # Happens only when Sphinx autodoc imports it and this module is # not installed. teacher_model = 'foo.Bar' pupil_model = 'foo.Bar'
Temporary test cases¶
Note that above snippet is what I would call a temporary test case. It is not part of the Lino test suite, I just tested it manually while writing this blog entry, using:
$ python -m doctest docs/blog/2015/1012.rst
And note how such temporary test cases (until Saturday) had to start with something like…
>>> import os >>> os.environ['DJANGO_SETTINGS_MODULE'] = 'lino.projects.docs.settings.demo'
while now (thanks to the extended
lino.startup()) it is easier
>>> import lino >>> lino.startup('lino_welfare.projects.std.settings.demo')