Re: Enforcing model representation invariants

2007-04-17 Thread Michael F. Robbins
On Tue, 2007-04-17 at 09:09 -0700, Vinay Sajip wrote: > Malcolm is right when he's talking about validation of user-entered > data. However, invariants are also used to catch programming errors; > it's certainly possible to have buggy business logic code which causes > invariant checks to fail. An

Re: Enforcing model representation invariants

2007-04-17 Thread Vinay Sajip
On Apr 17, 4:06 am, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote: > > My "big stick" solution is just to override the save() method of the > > model, and to have it swap the start and end fields. > > A conceptual problem with this approach is that it's doing validation in > the wrong place. Vali

Re: Enforcing model representation invariants

2007-04-16 Thread Malcolm Tredinnick
Hi Michael, On Mon, 2007-04-16 at 22:42 -0400, Michael F. Robbins wrote: > I have a model with two DateTimeFields, named start and end. As Python > datetime objects, I'd like to ensure that (start < end) for all valid > instances of this model. What's the right way to enforce this > invariant?

Enforcing model representation invariants

2007-04-16 Thread Michael F. Robbins
I have a model with two DateTimeFields, named start and end. As Python datetime objects, I'd like to ensure that (start < end) for all valid instances of this model. What's the right way to enforce this invariant? I tried making a custom Validator object and adding it to start.validator_list, a