Fix issue #2, fix inter-field message extraction, add asdict2(), fix All() so it won't lose children exceptions #12

Closed
wants to merge 8 commits into
from

Projects

None yet

3 participants

Contributor

All with tests demonstrating the purpose of the edits.

Oh, and update the Brazilian Portuguese translation.

nandoflorestan added some commits Jun 1, 2011
@nandoflorestan nandoflorestan Add a test for issue #2
...and on next commit we fix it.
48aa0c4
@nandoflorestan nandoflorestan Exception of issue #2 no longer occurs
...but I have another test case (see next commit).
7b9febe
@nandoflorestan nandoflorestan Fix the test,
...don't need it to be interactive anymore.
c8fd214
@nandoflorestan nandoflorestan Add a test (currently failing) for inter-field
...validation and message assignment.
8d7c6fd
@nandoflorestan nandoflorestan Add an asdict2() method to the Invalid exception
asdict() returns one item per leaf of the exception graph.
That does not cover my use case, which is not unlike
http://deformdemo.repoze.org/interfield/

So asdict2() returns more items in the dictionary, allowing you to
place error messages in more places of your form.

Originally I intended to replace the behaviour of asdict(), but
in so doing I broke 4 other test cases, so I expect this kind of
change has to be made on a new API. Thus, asdict2().
057fa79
@nandoflorestan nandoflorestan Add test showing All() loses children exceptions.
This commit contains only the test, see next commit for the fix.
4f4627b
@nandoflorestan nandoflorestan Fix All() so it won't lose children exceptions a5d6e71
@nandoflorestan nandoflorestan Brazilian portuguese translation update.
Also removed the funny but non functional Texas locale.
08fe1f2
Owner
mcdonc commented Jun 23, 2011

Sorry I didn't get to this for Colander 0.9.3 (just released). I'll review it for the next version.

ravishi commented Jun 29, 2011

I had this same problem, and solved by replacing exc.msg and msgs.append(exc.msg) by exc.msg and msgs.extend(self.messages()). I think it's more cleaner. The only prob is that self.messages can return something like [None] and it'll break. But that can be easily fixed too.

Also, this requires some modifications on deform. I'll try to send you a patch later.

Contributor

I am OK with whatever implementation details as long as the tests I added pass...

ravishi commented Oct 18, 2011

Is this going to be merged into 0.9.4? I didnt't send the stuff I commented before because it wasn't necessary. In the end my solution was very close to nando's one. I hope it gets included in 0.9.4!

@mcdonc mcdonc closed this in a6b85dd Feb 23, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment