• StartedSummaryDescription wasn’t abstract. isip.ExamPolicy is no longer ProjectRelated (project) and no longer cal.ComponentBase (uid).

Fixed a bug in lino.utils.dumpy

Oops, the double dump test fails! The coming Lino version is not able to read her own dumps!

$ initdb_demo
Installed 1595 object(s) from 28 fixture(s)
INFO Lino initdb done ('std', 'few_countries', 'few_cities', 'few_languages', 'props', 'cbss', 'democfg', 'demo', 'demo_
events', 'cpas_eupen') on database t:\data\luc\lino_local\dsbe\dsbe_test.db.

$ python manage.py dumpdata --format py > fixtures/a.py

Until here everything seems okay. But then:

$ python manage.py initdb a
Problem installing fixture 't:\data\luc\lino_local\dsbe\fixtures\a.py': Traceback (most recent call last):
  File "l:\snapshots\django\django\core\management\commands\loaddata.py", line 186, in handle
    for obj in objects:
  File "t:\hgwork\lino\lino\utils\dumpy.py", line 456, in deserialize
    for o in expand(obj):
  File "t:\hgwork\lino\lino\utils\dumpy.py", line 442, in expand
    for o in obj:
  File "t:\data\luc\lino_local\dsbe\fixtures\a.py", line 907, in contacts_person_objects
    yield create_contacts_person(112,u'EE',12,None,u'78003',u'Saffre Luc',u'',u'',u'Uus',u'1',u'',u'Vana-Vigala k\xfcla',u'de',u'',u'',u'',u'',u'',u'',u'1968-06-01',u'Luc',u'Saffre',u'','M')
  File "t:\data\luc\lino_local\dsbe\fixtures\a.py", line 161, in create_contacts_person
    return create_child(contacts_Partner,partner_ptr_id,contacts_Person,country_id=country_id,city_id=city_id,region_id=region_id,zip_code=zip_code,name=name,addr1=addr1,street_prefix=street_prefix,street=street,street_no=street_no,street_box=street_box,addr2=addr2,language=language,email=email,url=url,phone=phone,gsm=gsm,fax=fax,remarks=remarks,birth_date=birth_date,first_name=first_name,last_name=last_name,title=title,gender=gender)
  File "t:\hgwork\lino\lino\utils\mti.py", line 278, in create_child
Exception: create_child() Person 112 from Partner : ignored non-local fields {'fax': u'', 'name': u'Saffre Luc', 'language': u'de', 'url': u'', 'street_box': u'', 'street_no': u'1', 'phone': u'', 'street': u'Uus', 'addr2': u'Vana-Vigala k\xfcla', 'addr1': u'', 'remarks': u'', 'street_prefix': u'', 'gsm': u'', 'email': u'', 'zip_code': u'78003'}

Looking into the fixture, we can see that lino.utils.dumpy indeed creates the following function:

def create_contacts_person(partner_ptr_id, country_id, city_id, region_id, zip_code, name, addr1, street_prefix, street, street_no, street_box, addr2, language, email, url, phone, gsm, fax, remarks, birth_date, first_name, last_name, title, gender):
    return create_child(contacts_Partner,partner_ptr_id,contacts_Person,country_id=country_id,city_id=city_id,region_id=region_id,zip_code=zip_code,name=name,addr1=addr1,street_prefix=street_prefix,street=street,street_no=street_no,street_box=street_box,addr2=addr2,language=language,email=email,url=url,phone=phone,gsm=gsm,fax=fax,remarks=remarks,birth_date=birth_date,first_name=first_name,last_name=last_name,title=title,gender=gender)

which is wrong because street, addr1 etc are stored in Partner, not in Person. Seems that Django has a different definition of local_fields than what I thought:

>>> from django.conf import settings
>>> settings.LINO.startup()
>>> print [f.name for f in settings.LINO.modules.contacts.Person._meta.local_fields]
['partner_ptr', 'country', 'city', 'region', 'zip_code', 'name', 'addr1', 'street_prefix', 'street', 'street_no', 'street_box', 'addr2', 'language', 'email', 'url', 'phone', 'gsm', 'fax', 'remarks', 'birth_date', 'first_name', 'last_name', 'title', 'gender']

What we want is:

>>> print [f.name for f,m in settings.LINO.modules.contacts.Person._meta.get_fields_with_model() if m is None]
['partner_ptr', 'birth_date', 'first_name', 'last_name', 'title', 'gender']

Seems that this bug has “always” been there, but didn’t lead to a failure before I changed the “ignored non-local fields” warning into an Exception (/2012/0929).

Dumpy resolving cirular dependencies

The dumpy Serializer now generates, as a comment, an overview of the unresolved circular dependencies. This helped me to discover that it abandoned the resolution process too early, causing fixtures to have a lot of deferred instances when getting loaded back.

Cool! Ich hatte mich schon gewundert (aber war der Sache aus Zeitmangel nie auf den Grund gegangen), weshalb er immer noch so viele “deferred” meldet beim einlesen eines Dumps.

14.40 Uhr: Uff:

lsaffre@lino:/usr/local/django/test_dsbe$ python manage.py dumpdata --format py > fixtures/a.py
INFO Source version is 1.0 : no migration needed
INFO Loading /usr/local/django/test_dsbe/fixtures/a.py...
Installed 53248 object(s) from 1 fixture(s)
INFO Lino initdb done ('a',) on database test_dsbe.
lsaffre@lino:/usr/local/django/test_dsbe$ python manage.py dumpdata --format py > fixtures/b.py
lsaffre@lino:/usr/local/django/test_dsbe$ diff fixtures/a.py fixtures/b.py


Noch Tests und Bugfixes.

  • contact_role wurde nicht automatisch zugewiesen
  • assign_coach gab dict statt JsonResponse zurück. Ich Wirklichkeit geben success_response und error_response jetzt ebenfalls dicts zurück. Eine RowAction.run() muss entweder None oder einen dict zurückgeben, nicht eine action_response().
  • watch_tim