Thomas Waldmann <t...@waldmann-edv.de> writes: >> [Wed Oct 01 17:50:31 2014] [error] [client 176.194.6.204] File >> "/usr/lib/python2.7/dist-packages/MoinMoin/Page.py", line 212, in get_body >> [Wed Oct 01 17:50:31 2014] [error] [client 176.194.6.204] f = >> codecs.open(self._text_filename(), 'rb', config.charset) >> [Wed Oct 01 17:50:31 2014] [error] [client 176.194.6.204] IOError: [Errno >> 36] File name too long: '...' [...] >> What would be the best way to catch this exception and log a short, >> standard message instead? > > I guess you could catch it at the place I quoted. Make sure you do not > catch stuff also which you did not want to catch. Maybe check errno? > > Important: run your code, practically try if it really fixes the > problem. Run our unit tests (== run ./pytest from top level dir). > >> I am proficient in Python, but not in moinmoin. So my question is mostly >> *where* to insert the necessary code, and how to generate the error >> message (just print to stderr, or is there a logging function I should >> use?). > > We use the stdlib "logging", just look in some code to find how it is > usually imported and used (our "logging" is NOT the logging module object). > >> Ideally, I'd also like to change something in /etc rather than >> changing e.g. "/usr/lib/python2.7/dist-packages/MoinMoin/wsgiapp.py", so >> that the changes are not lost on the next update. > > If you get the changes done asap and get them adopted upstream (== by > me), they could be in a release quicker than you think. :D
How about this patch? diff --git a/MoinMoin/Page.py b/MoinMoin/Page.py --- a/MoinMoin/Page.py +++ b/MoinMoin/Page.py @@ -217,6 +217,10 @@ # never store empty pages, so this is detectable and also # safe when passed to a function expecting a string) return "" + elif er.errno == errno.ENAMETOOLONG: + # If the name is too long, the page can't exist on this + # system either. + return "" else: raise It fixed the issue for me, and applies cleanly against the 1.9 hg repository. I decided against an error message and instead opted to treat this like a file-not-found error (which, in some way it is). ./pytest also runs fine with the patched source. Best, -Nikolaus -- GPG encrypted emails preferred. Key id: 0xD113FCAC3C4E599F Fingerprint: ED31 791B 2C5C 1613 AF38 8B8A D113 FCAC 3C4E 599F »Time flies like an arrow, fruit flies like a Banana.« ------------------------------------------------------------------------------ Meet PCI DSS 3.0 Compliance Requirements with EventLog Analyzer Achieve PCI DSS 3.0 Compliant Status with Out-of-the-box PCI DSS Reports Are you Audit-Ready for PCI DSS 3.0 Compliance? Download White paper Comply to PCI DSS 3.0 Requirement 10 and 11.5 with EventLog Analyzer http://p.sf.net/sfu/Zoho _______________________________________________ Moin-user mailing list Moin-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/moin-user