Mercurial > p > roundup > code
view roundup/dist/command/build.py @ 5548:fea11d05110e
Avoid errors from selecting "no selection" on multilink (issue2550722).
As discussed in issue 2550722 there are various cases where selecting
"no selection" on a multilink can result in inappropriate errors from
Roundup:
* If selecting "no selection" produces a null edit (a value was set in
the multilink in an edit with an error, then removed again, along
with all other changes, in the next form submission), so the page is
rendered from the form contents including the "-<id>" value for "no
selection" for the multilink.
* If creating an item with a nonempty value for a multilink has an
error, and the resubmission changes that multilink to "no selection"
(and this in turn has subcases, according to whether the creation
then succeeds or fails on the resubmission, which need fixes in
different places in the Roundup code).
All of these cases have in common that it is expected and OK to have a
"-<id>" value for a submission for a multilink when <id> is not set in
that multilink in the database (because the original attempt to set
<id> in that multilink had an error), so the hyperdb.py logic to give
an error in that case is thus removed. In the subcase of the second
case where the resubmission with "no selection" has an error, the
templating code tries to produce a menu entry for the "-<id>"
multilink value, which also results in an error, hence the
templating.py change to ignore such values in the list for a
multilink.
| author | Joseph Myers <jsm@polyomino.org.uk> |
|---|---|
| date | Thu, 27 Sep 2018 11:33:01 +0000 |
| parents | f2fade4552c5 |
| children | 42bf0a707763 |
line wrap: on
line source
# # Copyright (C) 2009 Stefan Seefeld # All rights reserved. # For license terms see the file COPYING.txt. # from __future__ import print_function from roundup import msgfmt from distutils.command.build import build as base import os from glob import glob def list_message_files(suffix=".po"): """Return list of all found message files and their intallation paths""" _files = glob("locale/*" + suffix) _list = [] for _file in _files: # basename (without extension) is a locale name _locale = os.path.splitext(os.path.basename(_file))[0] _list.append((_file, os.path.join( "share", "locale", _locale, "LC_MESSAGES", "roundup.mo"))) return _list def check_manifest(): """Check that the files listed in the MANIFEST are present when the source is unpacked. """ try: f = open('MANIFEST') except: print('\n*** SOURCE WARNING: The MANIFEST file is missing!') return try: manifest = [l.strip() for l in f.readlines()] finally: f.close() err = set([line for line in manifest if not os.path.exists(line)]) # ignore auto-generated files err = err - set(['roundup-admin', 'roundup-demo', 'roundup-gettext', 'roundup-mailgw', 'roundup-server', 'roundup-xmlrpc-server']) if err: n = len(manifest) print('\n*** SOURCE WARNING: There are files missing (%d/%d found)!'%( n-len(err), n)) print('Missing:', '\nMissing: '.join(err)) def build_message_files(command): """For each locale/*.po, build .mo file in target locale directory""" for (_src, _dst) in list_message_files(): _build_dst = os.path.join("build", _dst) command.mkpath(os.path.dirname(_build_dst)) command.announce("Compiling %s -> %s" % (_src, _build_dst)) mo = msgfmt.Msgfmt(_src).get() open(_build_dst, 'wb').write(mo) class build(base): def run(self): check_manifest() build_message_files(self) base.run(self)
