20130903 (Tuesday, 03 September 2013)¶
newcomers.NewClients.param_defaults() returned invalid keyword ‘observed_event’¶
Fixed a which occured even in the test suite.
Getting the user in a Pisa template¶
Joe sent in a small patch to allow access to current request when printing using Pisa, useful to get current user.
Joe, you suggested to use a variable name request
to hold the
Django request, but I think it is better to use the variable ar
(for ActionRequest
)
because this is also given for appy templates and because it
has some more possibilities:
{{ar.request.user}} : returns the user
{{ar.user}} : returns the user
{{ar.subst_user}} : None if user is acting as herself, otherwise the substituted user
{{ar.get_user()}} : Shortcut for ar.subst_user or ar.user
Wrote a new tutorial lino_book.projects.pisa
to demonstrate and
test this.
‘Site’ object has no attribute ‘modules’¶
Joe reported “I’m unable to run Lino with latest pypi versions of Lino, djangosite, North …. after upgrading everything I have to downgrade djangosite to 0.1.4. There is an error that site.modules is not defined.”
To reproduce it, I create a virgin Python environment and try the lino.tutorial.quickstart tutorial:
$ virtualenv t
$ . t/bin/activate
$ pip install lino
$ cd ~/hgwork/lino/docs/tutorials/quickstart
$ python manage.py initdb_demo --traceback
This produces indeed:
INFO Started manage.py initdb_demo --traceback (using mysite.settings) --> PID 7754
INFO This is Lino Così 0.1 using djangosite 0.1.7, Django 1.5.2, Python 2.7.3, Babel 1.3, Lino 1.6.11, Jinja 2.7.1, Sphinx 1.2b1, python-dateutil 2.1, OdfPy ODFPY/0.9.6, docutils 0.11, suds (not installed), PyYaml 3.10, Appy 0.8.5 (2013/08/12 09:51).
Traceback (most recent call last):
File "/home/luc/tmp/t/local/lib/python2.7/site-packages/django/core/management/base.py", line 222, in run_from_argv
self.execute(*args, **options.__dict__)
File "/home/luc/tmp/t/local/lib/python2.7/site-packages/django/core/management/base.py", line 254, in execute
self.validate()
File "/home/luc/tmp/t/local/lib/python2.7/site-packages/django/core/management/base.py", line 280, in validate
num_errors = get_validation_errors(s, app)
File "/home/luc/tmp/t/local/lib/python2.7/site-packages/django/core/management/validation.py", line 35, in get_validation_errors
for (app_name, error) in get_app_errors().items():
File "/home/luc/tmp/t/local/lib/python2.7/site-packages/django/db/models/loading.py", line 166, in get_app_errors
self._populate()
File "/home/luc/tmp/t/local/lib/python2.7/site-packages/django/db/models/loading.py", line 72, in _populate
self.load_app(app_name, True)
File "/home/luc/tmp/t/local/lib/python2.7/site-packages/django/db/models/loading.py", line 96, in load_app
models = import_module('.models', app_name)
File "/home/luc/tmp/t/local/lib/python2.7/site-packages/django/utils/importlib.py", line 35, in import_module
__import__(name)
File "/home/luc/tmp/t/local/lib/python2.7/site-packages/djangosite/models.py", line 31, in <module>
settings.SITE.startup()
File "/home/luc/tmp/t/local/lib/python2.7/site-packages/djangosite/__init__.py", line 320, in startup
self.do_site_startup()
File "/home/luc/tmp/t/local/lib/python2.7/site-packages/lino/ui/__init__.py", line 669, in do_site_startup
super(Site,self).do_site_startup()
File "/home/luc/tmp/t/local/lib/python2.7/site-packages/lino/__init__.py", line 339, in do_site_startup
startup_site(self)
File "/home/luc/tmp/t/local/lib/python2.7/site-packages/lino/core/kernel.py", line 173, in startup_site
self.modules.define(model._meta.app_label,model.__name__,model)
AttributeError: 'Site' object has no attribute 'modules'
INFO Done manage.py initdb_demo --traceback (PID 7754)
Thank you, Joe, for reporting this problem.
Another symptom in that environment:
$ python setup.py test
running test
Traceback (most recent call last):
File "setup.py", line 3, in <module>
setup(**SETUP_INFO)
File "/usr/lib/python2.7/distutils/core.py", line 152, in setup
dist.run_commands()
File "/usr/lib/python2.7/distutils/dist.py", line 953, in run_commands
self.run_command(cmd)
File "/usr/lib/python2.7/distutils/dist.py", line 972, in run_command
cmd_obj.run()
File "/home/luc/tmp/t/local/lib/python2.7/site-packages/distribute-0.6.24-py2.7.egg/setuptools/command/test.py", line 127, in run
self.distribution.fetch_build_eggs(self.distribution.install_requires)
File "/home/luc/tmp/t/local/lib/python2.7/site-packages/distribute-0.6.24-py2.7.egg/setuptools/dist.py", line 245, in fetch_build_eggs
parse_requirements(requires), installer=self.fetch_build_egg
File "/home/luc/tmp/t/local/lib/python2.7/site-packages/distribute-0.6.24-py2.7.egg/pkg_resources.py", line 588, in resolve
raise VersionConflict(dist,req) # XXX put more info here
pkg_resources.VersionConflict: (djangosite 0.1.7 (/home/luc/tmp/t/lib/python2.7/site-packages), Requirement.parse('djangosite==0.1.5'))
So it is time to make a new release. But first answer the question: why did this error pass the test suites and make it into a released version?
Not the reason, but disturbing is the bug that the message
“using djangosite 0.1.7, Django 1.5.2, …”
didn’t include the North version number.
This was in north.north_site.Site()
Fixed.
Cleanup my __init__.py
files¶
After reading
5 Simple Rules For Building Great Python Packages
I started to move the Site classes out of __init__.py
into a
separate file site.py
In fact I have always been wanting that.
Application code needs no change since it continues to
do from lino.ui import Site
.
The difference is just that it “looks better”.
One side effect is that all my references in docs need an update
Need to change all lino.Site
to lino.Site
.
A new icon for external links¶
Although I liked very much the wikipedia icon for the “Open this panel in own window” link displayed behind every “main item header” (see 2013-08-23)
Gerd now suggested another icon which looks even better.
Slave tables with more than 15 rows¶
Fixed a problem “Slave tables with more than 15 rows” reported by Gerd and Joe. Test case and description in Lino Così Developer Guide.
Difference between lino.ui.Site and lino.Site¶
I removed the split between lino.ui.Site and lino.Site which was historic and obsolete.
There is no longer a class lino.ui.Site, everything is in lino.Site.
Application code usually does
from lino.projects.std.settings import *
and therefore needs no change.
But in case you copied some tutorial and have
from lino.ui import Site
then change this to
from lino import Site
.
Miscellaneous¶
Lino Welfare : EntryStates has no attribute “accepted”