/docs/blog/2010/1207.rst

https://code.google.com/p/lino/ · ReStructuredText · 111 lines · 80 code · 31 blank · 0 comment · 0 complexity · c5ff141208d6b18e29230789cf956761 MD5 · raw file

  1. 20101207
  2. ========
  3. Setting quickfilter in a Detail window
  4. --------------------------------------
  5. Folgender Fehler trat auf, wenn man in einem Detail-Fenster einen quick filter setzte,
  6. der den aktuellen Record unsichtbar machte::
  7. File "/var/snapshots/lino/lino/ui/extjs/ext_ui.py", line 162, in elem2rec_detailed
  8. i = id_list.index(elem.pk)
  9. ValueError: list.index(x): x not in list
  10. Richtig, den Fall hatte ich im :doc:`neuen Algotrithmus </blog/2010/1116>`
  11. in :func:`elem2rec_detailed <lino.ui.extjs.ext_ui.elem2rec_detailed>`
  12. noch nicht bedacht.
  13. Was muss der Server dann eigentlich tun?
  14. Das hatten wir doch schonmal beschlossen, oder?
  15. Richtig: der Client (:js:func:`Lino.FormPanel.goto_record_id` in der :xfile:`lino.js`)
  16. testet das wie folgt::
  17. if (rec.navinfo && rec.navinfo.recno == 0) {
  18. /*
  19. recno 0 means "the requested pk exists but is not contained in the requested queryset".
  20. This can happen after search_change on a detail.
  21. */
  22. Jetzt gibt auch der neue Algorithmus `recno=0` zur?ck, wenn der Fall auftritt.
  23. Fehler beim Einf?gen eines neuen Vertrags
  24. -----------------------------------------
  25. Wenn man Vertragsart nicht ausf?llte (und die Firmenart keine
  26. :attr:`Standard-Vertragsart <dsbe.CompanyType>` hatte),
  27. dann kam keine Fehlermeldung in der Statuszeile, sondern ein
  28. Alert-Fenster "Failur: Ajax communication failed".
  29. Auf dem Server war n?mlich inzwischen folgendes passiert::
  30. Traceback (most recent call last): 1 SVN-14540, python-dateuti
  31. File "/var/snapshots/django/django/core/handlers/wsgi.py", line 265, in __call__ 2010] [error] Starting user interface lino.ui.extjs
  32. response = self.get_response(request)
  33. File "/var/snapshots/django/django/core/handlers/base.py", line 160, in get_response0] [error] /var/snapshots/django/django/core/context_processors.py:27: DeprecationWarning: The c
  34. response = self.handle_uncaught_exception(request, resolver, sys.exc_info())d.
  35. File "/var/snapshots/django/django/core/handlers/base.py", line 109, in get_responseog
  36. response = callback(request, *callback_args, **callback_kwargs)
  37. File "/var/snapshots/lino/lino/ui/extjs/ext_ui.py", line 764, in api_list_view
  38. return self.form2obj_and_save(request,rh,request.POST,instance,force_insert=True)
  39. File "/var/snapshots/lino/lino/ui/extjs/ext_ui.py", line 656, in form2obj_and_save
  40. elem.full_clean()
  41. File "/var/snapshots/lino/lino/modlib/dsbe/models.py", line 763, in full_clean
  42. self.type = self.company.type.contract_type
  43. File "/var/snapshots/django/django/db/models/fields/related.py", line 316, in __set__
  44. (instance._meta.object_name, self.field.name))
  45. ValueError: Cannot assign None: "Contract.type" does not allow null values.
  46. Richtig, da war noch ein Bug. Behoben.
  47. Babel fields
  48. ------------
  49. - New module `lino.utils.babel`.
  50. The following fields are now "babel fields":
  51. | :attr:`dsbe.ContractType.name`
  52. | :attr:`contacts.ContactType.name`
  53. | :attr:`contacts.CompanyType.name` and :attr:`contacts.CompanyType.abbr`
  54. Updated the fixtures for these cases.
  55. Beobachtung am Rande. Erste Implementierung war::
  56. def add_lang_field(model,name,*args,**kw):
  57. f = getattr(model,name)
  58. ...
  59. model.add_to_class(name + '_' + lang,newfield)
  60. Aber::
  61. Exception occurred:
  62. File "t:\hgwork\lino\lino\modlib\dsbe\models.py", line 884, in add_lang_field
  63. f = getattr(model,name)
  64. AttributeError: type object 'ContractType' has no attribute 'name'
  65. Das fand ich komisch, denn folgendes funktioniert::
  66. class A(object):
  67. a = 'foo'
  68. f = getattr(A,'a')
  69. print f
  70. Das liegt aber daran, dass Django-Modelle eine `__metaclass__` definieren,
  71. die in der Klasse einiges umkrempelt. Also statt `getattr(model,name)`
  72. muss man `f = model._meta.get_field()` machen.
  73. Miscellaneous
  74. -------------
  75. - New field `dsbe.ContractType.ref`.
  76. - Contactable.address now returns only the address, not the name.
  77. - moved default_language from lino.tools to lino.utils.babel
  78. - In mixins.uploadable kam ein Traceback
  79. `NameError: global name 'logger' is not defined`
  80. Released :doc:`/releases/2010/1207` in Eupen.