[Django] #12595: Localflavor bad arguments handling

0 views
Skip to first unread message

Django

unread,
Jan 12, 2010, 4:20:15 PM1/12/10
to djang...@holovaty.com, django-...@googlegroups.com
#12595: Localflavor bad arguments handling
----------------------------------------+-----------------------------------
Reporter: sayane | Owner: nobody
Status: new | Milestone: 1.2
Component: django.contrib.localflavor | Version: SVN
Keywords: | Stage: Unreviewed
Has_patch: 1 |
----------------------------------------+-----------------------------------
A lot of form fields in django.contrib.localflavor handles arguments to
{{{__init__()}}} in a bad way.

{{{
def __init__(self, *args, **kwargs):
super(PLPESELField, self).__init__(r'^\d{11}$',
max_length=None, min_length=None, *args, **kwargs)
}}}

Every line like first one should be fixed like this:

{{{
def __init__(self, max_length=None, min_length=None, *args, **kwargs):
}}}

Because if someone will pass {{{max_length}}} or {{{min_length}}} argument
to {{{__init__()}}} it will fail (multiple
{{{min_length}}}/{{{max_length}}} arguments - additional one will be in
{{{kwargs}}}).

It is a big problem, if i'm trying to do something like this:

{{{
class PostalCodeField(models.CharField):
def formfield(self, **kwargs):
kwargs.setdefault("form_class", PLPostalCodeField)
return super(self.__class__, self).formfield(**kwargs)
}}}
because {{{django.db.models.CharField}}} sets {{{max_length}}} to
{{{self.max_length}}}.

I'm attaching patch to fix polish localflavor.

--
Ticket URL: <http://code.djangoproject.com/ticket/12595>
Django <http://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Jan 12, 2010, 4:21:37 PM1/12/10
to djang...@holovaty.com, django-...@googlegroups.com
#12595: Localflavor bad arguments handling
-------------------------------------------------+--------------------------
Reporter: sayane | Owner: nobody
Status: new | Milestone: 1.2
Component: django.contrib.localflavor | Version: SVN
Resolution: | Keywords:
Stage: Unreviewed | Has_patch: 1
Needs_docs: 0 | Needs_tests: 0
Needs_better_patch: 0 |
-------------------------------------------------+--------------------------
Changes (by sayane):

* cc: say...@gmail.com (added)
* needs_better_patch: => 0
* needs_tests: => 0
* needs_docs: => 0

--
Ticket URL: <http://code.djangoproject.com/ticket/12595#comment:1>

Django

unread,
Jan 12, 2010, 4:48:11 PM1/12/10
to djang...@holovaty.com, django-...@googlegroups.com
#12595: Localflavor bad arguments handling
-------------------------------------------------+--------------------------
Reporter: sayane | Owner: nobody
Status: new | Milestone: 1.2
Component: django.contrib.localflavor | Version: SVN
Resolution: | Keywords:
Stage: Accepted | Has_patch: 1
Needs_docs: 0 | Needs_tests: 0
Needs_better_patch: 0 |
-------------------------------------------------+--------------------------
Changes (by jezdez):

* stage: Unreviewed => Accepted

--
Ticket URL: <http://code.djangoproject.com/ticket/12595#comment:2>

Django

unread,
Jan 30, 2010, 10:52:21 AM1/30/10
to djang...@holovaty.com, django-...@googlegroups.com
#12595: Localflavor bad arguments handling
-------------------------------------------------+--------------------------
Reporter: sayane | Owner: jezdez
Status: new | Milestone: 1.2
Component: django.contrib.localflavor | Version: SVN
Resolution: | Keywords:
Stage: Accepted | Has_patch: 1
Needs_docs: 0 | Needs_tests: 0
Needs_better_patch: 0 |
-------------------------------------------------+--------------------------
Changes (by jezdez):

* owner: nobody => jezdez

--
Ticket URL: <http://code.djangoproject.com/ticket/12595#comment:3>

Django

unread,
Dec 20, 2010, 8:32:42 PM12/20/10
to djang...@holovaty.com, django-...@googlegroups.com
#12595: Localflavor bad arguments handling
-------------------------------------------------+--------------------------
Reporter: sayane | Owner: jezdez
Status: new | Milestone:
Component: django.contrib.localflavor | Version:
Resolution: | Keywords:
Stage: Accepted | Has_patch: 1
Needs_docs: 0 | Needs_tests: 0
Needs_better_patch: 0 |
-------------------------------------------------+--------------------------
Changes (by anonymous):

* cc: carbonXT (added)

--
Ticket URL: <http://code.djangoproject.com/ticket/12595#comment:5>

Django

unread,
Jan 3, 2011, 5:16:52 AM1/3/11
to djang...@holovaty.com, django-...@googlegroups.com
#12595: Localflavor bad arguments handling
-------------------------------------------------+--------------------------
Reporter: sayane | Owner:
Status: new | Milestone:
Component: django.contrib.localflavor | Version:
Resolution: | Keywords:
Stage: Accepted | Has_patch: 1
Needs_docs: 0 | Needs_tests: 0
Needs_better_patch: 0 |
-------------------------------------------------+--------------------------
Changes (by jezdez):

* owner: jezdez =>

--
Ticket URL: <http://code.djangoproject.com/ticket/12595#comment:6>

Django

unread,
Apr 2, 2011, 1:48:24 AM4/2/11
to djang...@holovaty.com, django-...@googlegroups.com
#12595: Localflavor bad arguments handling
------------------------------------+-----------------------------------
Reporter: sayane | Owner:
Type: Bug | Status: new
Milestone: | Component: contrib.localflavor
Version: | Severity: Normal
Resolution: | Keywords:
Triage Stage: Accepted | Has patch: 1
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 |
------------------------------------+-----------------------------------
Changes (by mattmcc):

* type: => Bug
* severity: => Normal


--
Ticket URL: <http://code.djangoproject.com/ticket/12595#comment:7>

Django

unread,
Apr 7, 2011, 2:05:35 AM4/7/11
to django-...@googlegroups.com
#12595: Localflavor bad arguments handling
------------------------------------+-----------------------------------
Reporter: sayane | Owner:
Type: Bug | Status: new
Milestone: | Component: contrib.localflavor
Version: | Severity: Normal
Resolution: | Keywords:
Triage Stage: Accepted | Has patch: 1
Needs documentation: 0 | Needs tests: 1
Patch needs improvement: 0 |
------------------------------------+-----------------------------------
Changes (by julien):

* needs_tests: 0 => 1


--
Ticket URL: <http://code.djangoproject.com/ticket/12595#comment:8>

Django

unread,
Apr 29, 2011, 4:57:24 PM4/29/11
to django-...@googlegroups.com
#12595: Localflavor bad arguments handling
------------------------------------+-------------------------------------
Reporter: sayane | Owner:
Type: Bug | Status: new
Milestone: | Component: contrib.localflavor
Version: | Severity: Normal
Resolution: | Keywords:
Triage Stage: Accepted | Has patch: 1
Needs documentation: 0 | Needs tests: 1
Patch needs improvement: 1 | Easy pickings: 0
------------------------------------+-------------------------------------
Changes (by claudep):

* needs_better_patch: 0 => 1
* easy: => 0


Comment:

I basically see what's the problem and what to do. Now there is a lot of
similar changes to make, and I would like to know if I'm going in the
right direction before giving more time to this.

See my patch, and tell me if it's OK (and good practice) to pass
max_length and min_length to super as args (vs kwargs).
For tests, should I add field_kwargs to all tests, or add a second assert
with field_kwargs to all tests, or simply add field_kwargs once per test
case?

--
Ticket URL: <http://code.djangoproject.com/ticket/12595#comment:9>

Django

unread,
Apr 30, 2011, 12:16:53 PM4/30/11
to django-...@googlegroups.com
#12595: Localflavor bad arguments handling
------------------------------------+-------------------------------------
Reporter: sayane | Owner:
Type: Bug | Status: new
Milestone: | Component: contrib.localflavor
Version: | Severity: Normal
Resolution: | Keywords:
Triage Stage: Accepted | Has patch: 1
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
------------------------------------+-------------------------------------
Changes (by claudep):

* needs_better_patch: 1 => 0
* needs_tests: 1 => 0


Comment:

OK, fixed now in all localflavors. Tested in utils.assertFieldOutput.

--
Ticket URL: <http://code.djangoproject.com/ticket/12595#comment:10>

Django

unread,
Apr 30, 2011, 1:27:42 PM4/30/11
to django-...@googlegroups.com
#12595: Localflavor bad arguments handling
-------------------------------------+-------------------------------------
Reporter: sayane | Owner:
Type: Bug | Status: new
Milestone: | Component: contrib.localflavor
Version: | Severity: Normal
Resolution: | Keywords:
Triage Stage: Ready for | Has patch: 1
checkin | Needs tests: 0
Needs documentation: 0 | Easy pickings: 0
Patch needs improvement: 0 |
-------------------------------------+-------------------------------------
Changes (by jezdez):

* stage: Accepted => Ready for checkin


--
Ticket URL: <http://code.djangoproject.com/ticket/12595#comment:11>

Django

unread,
May 3, 2011, 7:52:05 AM5/3/11
to django-...@googlegroups.com
#12595: Localflavor bad arguments handling
-------------------------------------+-------------------------------------
Reporter: sayane | Owner: jezdez
Type: Bug | Status: closed
Milestone: | Component: contrib.localflavor
Version: | Severity: Normal
Resolution: fixed | Keywords:
Triage Stage: Ready for | Has patch: 1
checkin | Needs tests: 0
Needs documentation: 0 | Easy pickings: 0
Patch needs improvement: 0 |
-------------------------------------+-------------------------------------
Changes (by jezdez):

* owner: => jezdez
* status: new => closed
* resolution: => fixed


Comment:

In [16146]:
{{{
#!CommitTicketReference repository="" revision="16146"
Fixed #12595 -- Fixed bad arguments handling in localflavor form fields.
}}}

--
Ticket URL: </ticket/12595#comment:12>

Reply all
Reply to author
Forward
0 new messages