20111228¶
Bugfix: Comboboxes always showed “Page 1 of 1”, even if there were more than one pageful of choices.
There was also a little bug which struck only on my development server: If BuildMethod.use_webdav was True, but
lino.Lino.use_davlink
not, then he still usedlino.Lino.webdav_url
in some places.
Action confirmations¶
The “Clear cache” button on a lino.mixins.printable.CachedPrintable
was a gotcha which potentially had a user delete a WebDAV-edited document.
Lino needs to protect the user from accidentally deleting their changes.
The idea is that Lino asks an additional confirmation
“Are you sure you want to discard all changes in the generated file?”
when the user clicks on “Clear cache” and the document has been edited
after Lino generated it.
A first change was relatively easy:
In
lino.mixins.printable.CachedPrintable
: BooleanField must_build has been replaced by a DateTimeField build_time.
A second required change was in fact a long-waiting new feature
“action confirmations”.
For application code it is easy:
the rr.confirm()
call in the example below will raise an exception
if the user answers “No” to the question.
Here is how this looks in
lino.mixins.printable.ClearCacheAction
:
def run(self,rr,elem):
if elem.get_cache_mtime() != elem.build_time:
rr.confirm(1,
_("This will discard all changes in the generated file."),
_("Are you sure?"))
elem.build_time = None
elem.save()
return rr.ui.success_response("%s printable cache has been cleared." % elem,refresh=True)
The challenge was how to implement this without using cookies and sessions! Checkin
TODO:
write migration handler which sets the new build_time fields on existing data.
no confirmation needed it mtime is None (which happens for example when the file doesn’t exist)
Test wether the ‘contract_type’ and ‘provider’ fields of a jobs.Job are disabled when some (printed) contract exists.
Test for possible bugs.
Convert the “Delete” method to use the new feature. It would be good to have applications decide individually whether and how to confirm before deleting a record.
Inserting images using appy pod¶
The following problem appeared today:
Error while evaluating the expression "document(at=self.person.get_image_path(),anchor="as-char")" defined in the "from" part of a statement.
File "<string>", line 1, in <module>
File "l:\snapshots\appy-0.6.7\appy\pod\renderer.py", line 293, in importDocument
res = imp.run()
File "l:\snapshots\appy-0.6.7\appy\pod\doc_importers.py", line 224, in run
width, height = getSize(self.importPath, self.format)
File "l:\snapshots\appy-0.6.7\appy\pod\doc_importers.py", line 190, in getSize
return float(x)/pxToCm, float(y)/pxToCm
<type 'exceptions.TypeError'>: float() argument must be a string or a number
It was solved by getting the version 0.8.0 from https://launchpad.net/appy