Re: Validation-aware models: First stab

2006-03-15 Thread Christopher Lenz
> On 3/15/06, Christopher Lenz <[EMAIL PROTECTED]> wrote: >> I definitely agree that the model layer should do validation, as long >> as that doesn't mean it's the *only* layer that does validation >> (that's not how I understood the proposal, but some some of the >> comments seemed to imply that)

Re: Validation-aware models: First stab

2006-03-15 Thread gabor
Adrian Holovaty wrote: > On 3/15/06, Christopher Lenz <[EMAIL PROTECTED]> wrote: >> Example: the string representation of a date in may depend on the >> locale of the remote user, which the model knows nothing about. The >> conversion from string to datetime will need to happen in a layer >> that

Re: Validation-aware models: First stab

2006-03-15 Thread Adrian Holovaty
On 3/15/06, Christopher Lenz <[EMAIL PROTECTED]> wrote: > I definitely agree that the model layer should do validation, as long > as that doesn't mean it's the *only* layer that does validation > (that's not how I understood the proposal, but some some of the > comments seemed to imply that). I ma

Re: Validation-aware models: First stab

2006-03-15 Thread Christopher Lenz
Am 15.03.2006 um 07:39 schrieb Russell Keith-Magee: > Addressing the arguments against:: > 1) Validation shouldn't be in the model > > If validation isn't in the model, then the model is little more > than a light data container; if all you have is a light data > container, then the onus is on

Re: Validation-aware models: First stab

2006-03-14 Thread Russell Keith-Magee
On 3/13/06, Adrian Holovaty <[EMAIL PROTECTED] > wrote: Thoughts, criticisms? The only part I'm sketchy on is the side effectof converting the values to their Python data types. Thecleanliness/consistency is quite nice, but it's slightly not somethinga developer might expect. However, we can solve

Re: Validation-aware models: First stab

2006-03-14 Thread James Bennett
On 3/14/06, Amit Upadhyay <[EMAIL PROTECTED]> wrote: > This is based on a simplistic assumption that everytime we are talking about > validation in django context we are talking about model based validation. No, it's based on an assumption that the facilities for doing custom validation that curr

Re: Validation-aware models: First stab

2006-03-14 Thread Joseph Kocherhans
On 3/13/06, Christopher Lenz <[EMAIL PROTECTED]> wrote: > > Am 13.03.2006 um 08:00 schrieb Adrian Holovaty: > [snip] > > Thoughts, criticisms? The only part I'm sketchy on is the side effect > > of converting the values to their Python data types. The > > cleanliness/consistency is quite nice, but

Re: Validation-aware models: First stab

2006-03-14 Thread Amit Upadhyay
On 3/14/06, James Bennett <[EMAIL PROTECTED]> wrote: * It's conceptually simpler; instead of worrying about whichvalidation layer you got down to before an error occurred, you onlyhave to worry about two states: success and failure.* It's more logical; I still don't see any good reason why informat

Re: Validation-aware models: First stab

2006-03-14 Thread Ivan Sagalaev
Gábor Farkas wrote: >or have a new constructor, that takes a dictionary of strings: > >def myview(request): > try: > m = MyModel( request.POSTDATA) > m.save() > except SomethingFailedError: > //handle it > > I also proposed something like th

Re: Validation-aware models: First stab

2006-03-13 Thread Max Battcher
Gábor Farkas wrote: >> Thoughts, criticisms? The only part I'm sketchy on is the side effect >> of converting the values to their Python data types. The >> cleanliness/consistency is quite nice, but it's slightly not something >> a developer might expect. However, we can solve the latter through >

Re: Validation-aware models: First stab

2006-03-13 Thread Gábor Farkas
Jacob Kaplan-Moss wrote: > On Mar 13, 2006, at 9:41 PM, James Bennett wrote: >> Sure they can. Imagine explaining Django to someone who's never seen >> an MVC model before; if you told them "the model is where you provide >> all the information about a class of objects, and describe how it >> work

Re: Validation-aware models: First stab

2006-03-13 Thread Max Battcher
limodou wrote: > On 3/14/06, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote: >> On Tue, 2006-03-14 at 09:34 +0800, limodou wrote: >> [...] >>> -1 I agree with gabor. Many orm models don't process validation, and >>> these things should be implemented by manipulator. Why do so much >>> things in mode

Re: Validation-aware models: First stab

2006-03-13 Thread Max Battcher
limodou wrote: > Reasons sound very reasonable. But I think current implement in django > is enough. Maybe model with validation is better but unnecessary. We > have many ways to validate data before it saved in db. Any Security Foil-Hat will tell: Validate early and validate often. It makes no

Re: Validation-aware models: First stab

2006-03-13 Thread limodou
On 3/14/06, James Bennett <[EMAIL PROTECTED]> wrote: > > On 3/13/06, limodou <[EMAIL PROTECTED]> wrote: > > Maybe or maybe not. What django has implemented is exactly as what I > > said, I think the ways is good. And I remember there was a discussion > > about js invalidation, why we need this. Be

Re: Validation-aware models: First stab

2006-03-13 Thread James Bennett
On 3/13/06, limodou <[EMAIL PROTECTED]> wrote: > Maybe or maybe not. What django has implemented is exactly as what I > said, I think the ways is good. And I remember there was a discussion > about js invalidation, why we need this. Because we want to make > mistakes can be found early, but not un

Re: Validation-aware models: First stab

2006-03-13 Thread limodou
On 3/14/06, Jacob Kaplan-Moss <[EMAIL PROTECTED]> wrote: > > On Mar 13, 2006, at 9:41 PM, James Bennett wrote: > > Sure they can. Imagine explaining Django to someone who's never seen > > an MVC model before; if you told them "the model is where you provide > > all the information about a class of

Re: Validation-aware models: First stab

2006-03-13 Thread limodou
On 3/14/06, James Bennett <[EMAIL PROTECTED]> wrote: > > On 3/13/06, limodou <[EMAIL PROTECTED]> wrote: > > In most cases we do not do anything alone use model, but always there > > is a ui layer, such as gui or web. They have to do any such thing. > > There should be the ability to generate an HT

Re: Validation-aware models: First stab

2006-03-13 Thread Jacob Kaplan-Moss
On Mar 13, 2006, at 9:41 PM, James Bennett wrote: > Sure they can. Imagine explaining Django to someone who's never seen > an MVC model before; if you told them "the model is where you provide > all the information about a class of objects, and describe how it > works", they'd be awfully confused

Re: Validation-aware models: First stab

2006-03-13 Thread James Bennett
On 3/13/06, limodou <[EMAIL PROTECTED]> wrote: > In most cases we do not do anything alone use model, but always there > is a ui layer, such as gui or web. They have to do any such thing. There should be the ability to generate an HTML form for creating/changing an instance of a model, yes, but t

Re: Validation-aware models: First stab

2006-03-13 Thread limodou
On 3/14/06, limodou <[EMAIL PROTECTED]> wrote: > On 3/14/06, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote: > > > > On Tue, 2006-03-14 at 09:34 +0800, limodou wrote: > > [...] > > > > > > -1 I agree with gabor. Many orm models don't process validation, and > > > these things should be implemented b

Re: Validation-aware models: First stab

2006-03-13 Thread limodou
On 3/14/06, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote: > > On Tue, 2006-03-14 at 09:34 +0800, limodou wrote: > [...] > > > > -1 I agree with gabor. Many orm models don't process validation, and > > these things should be implemented by manipulator. Why do so much > > things in model? > > This i

Re: Validation-aware models: First stab

2006-03-13 Thread limodou
On 3/14/06, James Bennett <[EMAIL PROTECTED]> wrote: > > On 3/13/06, limodou <[EMAIL PROTECTED]> wrote: > > -1 I agree with gabor. Many orm models don't process validation, and > > these things should be implemented by manipulator. Why do so much > > things in model? > > Among other things, the mo

Re: Validation-aware models: First stab

2006-03-13 Thread Malcolm Tredinnick
On Tue, 2006-03-14 at 09:34 +0800, limodou wrote: [...] > > -1 I agree with gabor. Many orm models don't process validation, and > these things should be implemented by manipulator. Why do so much > things in model? This isn't really an argument, though. Other systems working differently is not

Re: Validation-aware models: First stab

2006-03-13 Thread James Bennett
On 3/13/06, limodou <[EMAIL PROTECTED]> wrote: > -1 I agree with gabor. Many orm models don't process validation, and > these things should be implemented by manipulator. Why do so much > things in model? Among other things, the model is the place where the types of data are specified for a parti

Re: Validation-aware models: First stab

2006-03-13 Thread limodou
On 3/13/06, Gábor Farkas <[EMAIL PROTECTED]> wrote: > > Adrian Holovaty wrote: > > > > EXAMPLE CODE: > > > > class Person(models.Model): > > name = models.CharField(maxlength=50) > > birthday = models.DateField() > > favorite_number = models.IntegerField() > > > p = Person(name='J

Re: Validation-aware models: First stab

2006-03-13 Thread Christopher Lenz
Am 13.03.2006 um 08:00 schrieb Adrian Holovaty: [snip] > Thoughts, criticisms? The only part I'm sketchy on is the side effect > of converting the values to their Python data types. The > cleanliness/consistency is quite nice, but it's slightly not something > a developer might expect. However, we

Re: Validation-aware models: First stab

2006-03-13 Thread Linicks
All, Validation aware models have seen allot of attention so far with a number of proposals out there. This proposal, like the others, has it's strengths and weaknesses. This method of validating models is a good start, and will surely evolve or be replaced over time. I believe that we need t

Re: Validation-aware models: First stab

2006-03-13 Thread Adrian Holovaty
On 3/13/06, Amit Upadhyay <[EMAIL PROTECTED]> wrote: > Does it mean AddManipulator/UpdateManipulator are going > away? Yes, the automatic manipulators are going away, but there will of course still be away to generate forms/manipulators automatically from a model. Adrian -- Adrian Holovaty holo

Re: Validation-aware models: First stab

2006-03-13 Thread Amit Upadhyay
HI Adrian,Does it mean AddManipulator/UpdateManipulator are going away?This way of doing things is inconsitant with handling custom forms. If it is, a good step for django ORM, a bad step for django web framework. Let me elaborate, this is my typical view:def confirm_email(request):    if not requ

Re: Validation-aware models: First stab

2006-03-13 Thread Gábor Farkas
Adrian Holovaty wrote: > > EXAMPLE CODE: > > class Person(models.Model): > name = models.CharField(maxlength=50) > birthday = models.DateField() > favorite_number = models.IntegerField() > p = Person(name='Joe', birthday='never', favorite_number='foo') p.validate() > {'bir

Validation-aware models: First stab

2006-03-12 Thread Adrian Holovaty
Just got back from a week-long Hawaii vacation, so I'm getting back into the Django groove. Earlier today I committed the first stab at validation-aware models on the magic-removal branch: http://code.djangoproject.com/changeset/2518 Here's how it works: * Model instances have a validate() meth