Re: US Zip Code Field

2010-05-03 Thread Russell Keith-Magee
On Tue, May 4, 2010 at 2:23 AM, quindraco  wrote:
> I noticed that there is no class us.models.USZipCodeField in
> django.contrib.localflavor.us, although there is a model for phone
> numbers.  The django guide for submitting patches says to discuss
> alternatives here first, so I wanted to do just that.

This really only applies when there is potential for disagreement
about the right way to implement a feature. When you're talking about
something as simple as a field for storing Zip codes, there really
isn't any discussion required.

> Thoughts?  Concerns?  Should this be modified?  It seems to work just
> fine for me.

Looks fine to me too. Obviously, it needs tests and documentation, but
there isn't really anything controversial in the implementation you
propose.

Yours,
Russ Magee %-)

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to django-develop...@googlegroups.com.
To unsubscribe from this group, send email to 
django-developers+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en.



US Zip Code Field

2010-05-03 Thread quindraco
I noticed that there is no class us.models.USZipCodeField in
django.contrib.localflavor.us, although there is a model for phone
numbers.  The django guide for submitting patches says to discuss
alternatives here first, so I wanted to do just that.  I cobbled
together some code by copying the phone number code and modifying it.
I discovered some buggy behaviour at first with max_length, so I ended
up modifying the form as well by removing the argument for it, since I
saw no purpose in it.  This brings it into line with the other forms,
none of whom specify max length.  I removed min length while I was at
it, for consistency.

The new form is identical to the old form, only with max and min
length removed:

class USZipCodeField(RegexField):
default_error_messages = {
'invalid': _('Enter a zip code in the format X or X-
.'),
}

def __init__(self, *args, **kwargs):
super(USZipCodeField, self).__init__(r'^\d{5}(?:-\d{4})?$',
  *args, **kwargs)

The new model is extremely similar to the telephone number model:

class ZipCodeField(CharField):

description = _("Zip code")

def __init__(self, *args, **kwargs):
kwargs['max_length'] = 10
super(ZipCodeField, self).__init__(*args, **kwargs)

def formfield(self, **kwargs):
from django.contrib.localflavor.us.forms import USZipCodeField
defaults = {'form_class': USZipCodeField}
defaults.update(kwargs)
return super(ZipCodeField, self).formfield(**defaults)

Thoughts?  Concerns?  Should this be modified?  It seems to work just
fine for me.

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to django-develop...@googlegroups.com.
To unsubscribe from this group, send email to 
django-developers+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en.



adodbapi 2.3.0 (the django version) released

2010-05-03 Thread VernonCole
I have just released a version of adodbapi which is intended
specifically for django compatibility.  It should be useful for four
different projects:

1) accessing Microsoft SQL and/or Microsoft ACCESS (JET) databases.

2) running django on IronPython

3) converting django to Python 3

4) multi-db support

This is intended to replace the forked versions of adodbapi which have
been used for the above projects, so that all of them can return to
this, the official trunk version.

http://sourceforge.net/projects/adodbapi contains the source code. Use
either the .zip downloads or the Mercurial feed.

The present version is for Windows only.  A future version will be
converted to use .NET (or mono) and therefore run on Linux IronPython.

 Please try this out if you can.
--
Vernon Cole

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to django-develop...@googlegroups.com.
To unsubscribe from this group, send email to 
django-developers+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en.