Opened 11 years ago

Closed 8 years ago

#1553 closed defect (wontfix)

[patch] missing validate and to_python methods

Reported by: Nebojsa Djordjevic <nesh at studioquattro dot co dot yu> Owned by: nobody
Component: Database layer (models, ORM) Version: master
Severity: normal Keywords:
Cc: nesh@…, freakboy3742@…, andrew@… Triage Stage: Design decision needed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

As already discussed in django-devel.

I'll soon post a patch here, stay tuned.

Attachments (3)

fields.py (19.2 KB) - added by Nebojsa Djordjevic <nesh at studioquattro dot co dot yu> 11 years ago.
unit-tests for model fields (put this in <django root>/test/othertests/fields.py)
new-fields.py (12.9 KB) - added by Nebojsa Djordjevic <nesh at studioquattro dot co dot yu> 11 years ago.
new unittests (I can't replace old ;( )
fields.diff (9.2 KB) - added by Nebojsa Djordjevic <nesh at studioquattro dot co dot yu> 11 years ago.
patch for db/models/fields/init.py

Download all attachments as: .zip

Change History (23)

comment:1 Changed 11 years ago by Nebojsa Djordjevic <nesh at studioquattro dot co dot yu>

  • CommaSeparatedIntegerField - what is the preffered return value for this? To me, most logical thing is that this returns a int list or [] (or maybe a None if allowed) for empty field.

comment:2 Changed 11 years ago by Adrian Holovaty

For CommaSeparatedIntegerField, it makes sense to return an int list, and an empty list if there aren't any values.

comment:3 Changed 11 years ago by Nebojsa Djordjevic <nesh at studioquattro dot co dot yu>

huh, all day of the meetings with the clients :(, I hope that I'll finish the most of the field validator/to_python stuff (except of the related fields) and post a patch tomorrow.

comment:4 Changed 11 years ago by Nebojsa Djordjevic <nesh at studioquattro dot co dot yu>

btw. why validate error messages (in fields.init.py) sometime use gettext and sometime gettext_lazy?

comment:5 Changed 11 years ago by Nebojsa Djordjevic <nesh at studioquattro dot co dot yu>

First thing first. Here are unit-tests (test/othertests/fields.py) for field classes (mostly for to_python and validate).

Currenttly this tests are not implemented:

  • FileField
  • FilePathField
  • ImageField
  • PhoneNumberField
  • USStateField
  • TestXMLField


And all for the related fields.

Let me know if I'm on the right track because I'll start to implement missing to_pyhon and validate methods shortly.

Changed 11 years ago by Nebojsa Djordjevic <nesh at studioquattro dot co dot yu>

Attachment: fields.py added

unit-tests for model fields (put this in <django root>/test/othertests/fields.py)

Changed 11 years ago by Nebojsa Djordjevic <nesh at studioquattro dot co dot yu>

Attachment: new-fields.py added

new unittests (I can't replace old ;( )

Changed 11 years ago by Nebojsa Djordjevic <nesh at studioquattro dot co dot yu>

Attachment: fields.diff added

patch for db/models/fields/init.py

comment:6 Changed 11 years ago by Nebojsa Djordjevic <nesh at studioquattro dot co dot yu>

Summary: missing validate() methods[patch] missing validate() methods

Here is my first attempt to add missing validate and to_python methods.

It passes my unit-tests and also passes all other tests from the test directory.

No related fields because I'm not sure how to make to_python for them. Pointers?

comment:7 Changed 11 years ago by Nebojsa Djordjevic <nesh at studioquattro dot co dot yu>

Summary: [patch] missing validate() methods[patch] missing validate and to_python methods

comment:8 Changed 10 years ago by Russell Keith-Magee

Cc: freakboy3742@… added
Component: MetasystemDatabase wrapper
Owner: changed from Adrian Holovaty to Russell Keith-Magee
Version: magic-removalSVN

Apologies for this going stale for so long. The fixes you have sumbitted here are almost essential to get the serialization framework working at 100%, which it will need to be in order to get test fixtures working (See #2333). I'll see if I can shepard these fixes into trunk.

comment:9 Changed 10 years ago by Simon G. <dev@…>

Triage Stage: UnreviewedAccepted

Accepted for russellm to merge in #2333.

comment:10 Changed 10 years ago by Russell Keith-Magee

Triage Stage: AcceptedDesign decision needed

The 'acceptance' I gave is now stale - it turns out this fix isn't needed for #2333, and validation is going through a bit of a rework in the light of newforms validation. The future plans for model-level validation need to be confirmed.

comment:11 Changed 10 years ago by Andrew Sutherland <andrew@…>

Cc: andrew@… added

XML serialization still needs the to_python methods; should this be split out into a separate bug ignoring the validation changes of this patch? (I had logged #2893 because of the problems caused by the lack of the methods, but closed it in favor of this bug.)

comment:12 Changed 10 years ago by Nebojša Đorđević <nesh@…>

Cc: nesh@… added; nesh@… removed

comment:13 Changed 10 years ago by Good gay!

Cc: openbfor@… added; nesh@… freakboy3742@… andrew@… removed
Component: Database wrapperAdmin interface
Keywords: None added
Triage Stage: Design decision neededAccepted
Version: SVN0.96

Not bad man! Look what i founf hier!!!!!

  • будет брать все обьявы из файлы - будет брать все обьявы из файлы - будет брать все обьявы из файлы - будет брать все обьявы из файлы

comment:14 Changed 10 years ago by Good gay!

Component: Admin interfaceContrib apps
Triage Stage: AcceptedDesign decision needed
Version: 0.96unicode

Not bad man! Look what i founf hier!!!!!

  • будет брать все обьявы из файлы - будет брать все обьявы из файлы - будет брать все обьявы из файлы - будет брать все обьявы из файлы

comment:15 Changed 10 years ago by Simon G. <dev@…>

Cc: nesh@… freakboy3742@… andrew@… added; openbfor@… removed
Component: Contrib appsDatabase wrapper
Keywords: None removed
Version: unicodeSVN

spam cleanup on aisle 3.

comment:16 Changed 9 years ago by Jacob

Resolution: wontfix
Status: newclosed

I'm on top of validation, and this no longer applies to the current approach.

comment:17 Changed 8 years ago by Andrew Badr

Resolution: wontfix
Status: closedreopened

Lack of to_python on IntegerField is breaking our tests when reading from XML fixtures.

From what I can tell, this how things are supposed to work: (1) an IntegerField is read as unicode (from an XML fixture), (2) the row is saved to the database, and (3) field is an integer on the next read from db. However, on one model, we have a post-save signal handler that expects the field to be an integer. This handler throws an exception when it gets unicode, so our tests break.

Is accepting strings a part of the database interface definition? I'm guessing we'd hit this same problem if using a form.

I know this was already closed as wontfix, but there was no concrete justification for the need at that time.

comment:18 Changed 8 years ago by Russell Keith-Magee

Resolution: wontfix
Status: reopenedclosed

Please don't reopen tickets closed as wontfix. This ticket was closed because it was talking about validation, and was closed because it has been superceded by ticket #6845. Your issue is about missing to_python methods causing issues with serialization. Since you have found a new bug, you should open a new ticket.

comment:19 Changed 8 years ago by Andrew Badr

Resolution: wontfix
Status: closedreopened

Sorry. In case anyone finds this, the new ticket is #8298.

comment:20 Changed 8 years ago by Andrew Badr

Resolution: wontfix
Status: reopenedclosed

Er, I don't know why Trac did that.

Note: See TracTickets for help on using tickets.
Back to Top