Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
GeometryField doesn't honor the required attribute
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  5 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Fidel Ramos  
View profile  
 More options Mar 25 2009, 1:20 pm
From: Fidel Ramos <fidelra...@gmail.com>
Date: Wed, 25 Mar 2009 10:20:17 -0700 (PDT)
Local: Wed, Mar 25 2009 1:20 pm
Subject: GeometryField doesn't honor the required attribute
django.contrib.gis.forms.fields.GeometryField completely ignores the
required attribute in its clean() method. Instead it checks if the
model field is nullable, which needlessly ties forms and model code. I
realized this because I have a model with a non-nullable GeometryField
but need a non-required GeometryField in my form, because if it's null
I set it inside clean().

I wanted to confirm if this should be considered a bug before opening
a ticket.

My proposed solution would be to call Field's clean() instead of
checking self.null.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Justin Bronn  
View profile  
 More options Mar 27 2009, 2:49 pm
From: Justin Bronn <jbr...@gmail.com>
Date: Fri, 27 Mar 2009 11:49:06 -0700 (PDT)
Local: Fri, Mar 27 2009 2:49 pm
Subject: Re: GeometryField doesn't honor the required attribute

On Mar 25, 12:20 pm, Fidel Ramos <fidelra...@gmail.com> wrote:

> My proposed solution would be to call Field's clean() instead of
> checking self.null.

Isn't the checking of `self.null` that you've identified as the
problem already in the `GeometryField.clean` method?  Are you
proposing a recursive call?

I agree that GeometryField is ripe to be improved -- but I'm unclear
on exactly what is the problem and the proposed solution here.

-Justin


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Fidel Ramos  
View profile  
 More options Mar 27 2009, 7:39 pm
From: Fidel Ramos <fidelra...@gmail.com>
Date: Fri, 27 Mar 2009 16:39:19 -0700 (PDT)
Local: Fri, Mar 27 2009 7:39 pm
Subject: Re: GeometryField doesn't honor the required attribute
On 27 mar, 19:49, Justin Bronn <jbr...@gmail.com> wrote:

> Isn't the checking of `self.null` that you've identified as the
> problem already in the `GeometryField.clean` method?  Are you
> proposing a recursive call?

> I agree that GeometryField is ripe to be improved -- but I'm unclear
> on exactly what is the problem and the proposed solution here.

Thanks for answering Justin.

I'll show the problem with a simple example. Suppose the following
form:

class MyForm(forms.Form):
    point = GeometryField(required=False)

Do you think the point field can be left blank and then the form
validates? Because "required" is an attribute used by the Field
superclass, one should assume that the point field could be left
blank, but because of GeometryField's not standard behaviour (/django/
contrib/gis/forms/fields.py, line 31), it raises a ValidationError.
This is because GeometryField checks a "null" attribute in its clean()
method, instead of "required". "null" isn't defined in any of the
standard Django forms' fields. I suppose that it was consciously made
that way for some reason, but I don't think it's worth breaking the
standard behaviour for form fields.

I see two ways of fixing this:

- Introduce a backwards-incompatible change so that GeometryField
doesn't use "null", and use "required" instead. I don't know if this
has impact in other parts of Django.

- Allow for "null" OR "required". If null is True or required is False
then the field should be allowed to be blank. This should be backwards-
compatible AFAIK.

I hope I made myself clearer this time. Opinions please? If this
should be fixed, and I seriously think it must, I'll open a ticket and
attach a patch.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Justin Bronn  
View profile  
 More options Mar 28 2009, 2:58 pm
From: Justin Bronn <jbr...@gmail.com>
Date: Sat, 28 Mar 2009 11:58:29 -0700 (PDT)
Local: Sat, Mar 28 2009 2:58 pm
Subject: Re: GeometryField doesn't honor the required attribute

> I hope I made myself clearer this time. Opinions please? If this
> should be fixed, and I seriously think it must, I'll open a ticket and
> attach a patch.

I see what you're talking about now, and I agree it's a bug.  Please
open up a ticket and we'll consider the design decisions there.
Thanks for the clarification.

-Justin


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Fidel Ramos  
View profile  
 More options Mar 30 2009, 5:48 pm
From: Fidel Ramos <fidelra...@gmail.com>
Date: Mon, 30 Mar 2009 14:48:40 -0700 (PDT)
Local: Mon, Mar 30 2009 5:48 pm
Subject: Re: GeometryField doesn't honor the required attribute
On 28 mar, 20:58, Justin Bronn <jbr...@gmail.com> wrote:

> I see what you're talking about now, and I agree it's a bug.  Please
> open up a ticket and we'll consider the design decisions there.
> Thanks for the clarification.

I did just that, it's ticket #10660: http://code.djangoproject.com/ticket/10660

I don't know if we could have this before 1.1, I'll make a patch as
soon as a design decision is reached.

Cheers.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »