Re: proposal: helper functions for validation

2007-09-11 Thread Marty Alchin
with proposed function names > and signatures, please go through it, and see if they make sense, and might > be useful for django. > > [1]: http://code.djangoproject.com/wiki/ValidationHelperFunctionsProposal What I'd recommend is that you make a mix-in class that you can use with

Re: proposal: helper functions for validation

2007-09-11 Thread Amit Upadhyay
On 9/11/07, Marty Alchin <[EMAIL PROTECTED]> wrote: > That said, I'd also recommend that if you're going to draw any > parallels with unittest assertions, you should probably do it > reliably. Your validate_exception() example was completely unreadable > to me, because it works quite differently t

Re: proposal: helper functions for validation

2007-09-11 Thread Marty Alchin
I'll chime in just for a few cents here. First, I think it's worth noting that most Python programmers find little value in how many characters they have to type. Sure, Python is generally less verbose than many other languages, but only to the extent of making it more readable. So kep readabilit

Re: proposal: helper functions for validation

2007-09-11 Thread Amit Upadhyay
On 9/11/07, Russell Keith-Magee <[EMAIL PROTECTED]> wrote: > > Well... no. assertEquals exists in Python unittests because > assertEquals exists in JUnit, and unittest emulates the JUnit API. > This API is, in turn, based on xUnit, which was derived from SUnit, > the original Smalltalk implementati

Re: proposal: helper functions for validation

2007-09-11 Thread Russell Keith-Magee
On 9/11/07, Amit Upadhyay <[EMAIL PROTECTED]> wrote: > On 9/11/07, Russell Keith-Magee <[EMAIL PROTECTED]> wrote: > > I'm afraid you're going to have a hard time convincing me that this is > > a good idea. I'm willing to entertain the idea of validation helpers > > if they genuinely add clarity -

Re: proposal: helper functions for validation

2007-09-11 Thread Amit Upadhyay
On 9/11/07, Russell Keith-Magee <[EMAIL PROTECTED]> wrote: > > I'm afraid you're going to have a hard time convincing me that this is > a good idea. I'm willing to entertain the idea of validation helpers > if they genuinely add clarity - but not if they are just a verbose > replacement for somethi

Re: proposal: helper functions for validation

2007-09-10 Thread Russell Keith-Magee
On 9/11/07, Amit Upadhyay <[EMAIL PROTECTED]> wrote: > On 9/10/07, Nis Jørgensen <[EMAIL PROTECTED]> wrote: > > > I don't like the transformation of strings into field values. How would > > you compare a field value to a string? > > Exactly my reason for not making it a method of BaseForm. If thin

Re: proposal: helper functions for validation

2007-09-10 Thread Amit Upadhyay
On 9/10/07, Nis Jørgensen <[EMAIL PROTECTED]> wrote: > > Russell Keith-Magee skrev: > > On 9/9/07, Amit Upadhyay <[EMAIL PROTECTED]> wrote: > > > >> Python unittest TestCase objects have a lot of helper functions like > >> assert_(), failUnless(), as

Re: proposal: helper functions for validation

2007-09-10 Thread Nis Jørgensen
Russell Keith-Magee skrev: > On 9/9/07, Amit Upadhyay <[EMAIL PROTECTED]> wrote: > >> Python unittest TestCase objects have a lot of helper functions like >> assert_(), failUnless(), assertEqual(), assertNotEqual() and so on[1]. If we >> had a similar set of h

Re: proposal: helper functions for validation

2007-09-09 Thread Honza Král
On 9/9/07, Russell Keith-Magee <[EMAIL PROTECTED]> wrote: > > On 9/9/07, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote: > > > > On Sun, 2007-09-09 at 21:46 +0800, Russell Keith-Magee wrote: > > > No - this has nothing to do with the test framework. It'

Re: proposal: helper functions for validation

2007-09-09 Thread Russell Keith-Magee
On 9/9/07, Amit Upadhyay <[EMAIL PROTECTED]> wrote: > Drawback if most of the times we are not using that feature, each validation > statement will have to contain a superfluous self. in the beginning. Whereas > helper functions can all be imported in the name space. Its only mi

Re: proposal: helper functions for validation

2007-09-09 Thread Russell Keith-Magee
On 9/9/07, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote: > > On Sun, 2007-09-09 at 21:46 +0800, Russell Keith-Magee wrote: > > No - this has nothing to do with the test framework. It's a set of > > helper functions to support writing clean_XXX methods. > >

Re: proposal: helper functions for validation

2007-09-09 Thread dummy
Hi, since your assert-function won't be like assert in python or UnitTests, you mix semantics nobody knows everywhere else. Please remember that assert Statements have special meanings depending on __DEBUG__ http://docs.python.org/ref/assert.html http://pyunit.sourceforge.net/pyunit.html#TESTC

Re: proposal: helper functions for validation

2007-09-09 Thread Malcolm Tredinnick
u proposing putting some methods > > into newforms.forms.BaseForm that only exist for supporting the test > > framework? I'm usually not in favour of that type of change because it's > > leaking stuff from the test framework, which is ideally entirely > > independent

Re: proposal: helper functions for validation

2007-09-09 Thread Russell Keith-Magee
ork? I'm usually not in favour of that type of change because it's > leaking stuff from the test framework, which is ideally entirely > independent of core functionality, into the core. No - this has nothing to do with the test framework. It's a set of helper functions to

Re: proposal: helper functions for validation

2007-09-09 Thread Amit Upadhyay
ature, each validation statement will have to contain a superfluous self. in the beginning. Whereas helper functions can all be imported in the name space. Its only minor syntactic sugar so to say, that we are after with this. -- Amit Upadhyay Vakow! www.vakow.com +91-9820-295-512 --~--~-

Re: proposal: helper functions for validation

2007-09-09 Thread Malcolm Tredinnick
On Sun, 2007-09-09 at 15:58 +0800, Russell Keith-Magee wrote: [...] > - I'm also inclined to continue the similarities, and make the > assertion functions members on BaseForm. This would allow a > significant simplification of your proposal, as the data locations > (i.e., self.cleaned_data) can be

Re: proposal: helper functions for validation

2007-09-09 Thread Russell Keith-Magee
On 9/9/07, Amit Upadhyay <[EMAIL PROTECTED]> wrote: > Python unittest TestCase objects have a lot of helper functions like > assert_(), failUnless(), assertEqual(), assertNotEqual() and so on[1]. If we > had a similar set of helper functions, possibly with more pythonic n

proposal: helper functions for validation

2007-09-08 Thread Amit Upadhyay
Python unittest TestCase objects have a lot of helper functions like assert_(), failUnless(), assertEqual(), assertNotEqual() and so on[1]. If we had a similar set of helper functions, possibly with more pythonic names, newform validation functions could be written a little more succinctly

Re: helper functions

2006-04-03 Thread Andy Dustman
On 3/31/06, Jacob Kaplan-Moss <[EMAIL PROTECTED]> wrote: > > On Mar 31, 2006, at 1:30 PM, Alan Bailey wrote: > > IsModified() > > This could be useful, but it's probably not worth doing since Django > would have to keep two copies of all your data in memory to figure > this out. Doubling the mem

Re: helper functions

2006-03-31 Thread Eugene Lazutkin
Jacob Kaplan-Moss wrote: >> >> IsModified() > > This could be useful, but it's probably not worth doing since Django > would have to keep two copies of all your data in memory to figure > this out. Doubling the memory footprint of Django isn't on my wish- > list :) One way to do it is to k

Re: helper functions

2006-03-31 Thread Jacob Kaplan-Moss
On Mar 31, 2006, at 1:30 PM, Alan Bailey wrote: > I don't see any documentation on helper methods for the django > objects. Most of this is actually already possible; specific instructions are below... > By helper methods I'm envisioning the following: > > IsModified() This could be useful,

helper functions

2006-03-31 Thread Alan Bailey
I don't see any documentation on helper methods for the django objects. By helper methods I'm envisioning the following: IsModified() - If an object is from the database and a field has been edited. IsNew() - This object is not in the database yet. I.e. it's new and won't be there until a sav