Opened 19 years ago

Closed 16 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: dev
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: no UI/UX: no

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> 19 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> 19 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> 19 years ago.
patch for db/models/fields/init.py

Download all attachments as: .zip

Change History (23)

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

  • 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 by Adrian Holovaty, 19 years ago

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

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

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 by Nebojsa Djordjevic <nesh at studioquattro dot co dot yu>, 19 years ago

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

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

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.

by Nebojsa Djordjevic <nesh at studioquattro dot co dot yu>, 19 years ago

Attachment: fields.py added

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

by Nebojsa Djordjevic <nesh at studioquattro dot co dot yu>, 19 years ago

Attachment: new-fields.py added

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

by Nebojsa Djordjevic <nesh at studioquattro dot co dot yu>, 19 years ago

Attachment: fields.diff added

patch for db/models/fields/init.py

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

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 by Nebojsa Djordjevic <nesh at studioquattro dot co dot yu>, 19 years ago

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

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

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 by Simon G. <dev@…>, 18 years ago

Triage Stage: UnreviewedAccepted

Accepted for russellm to merge in #2333.

comment:10 by Russell Keith-Magee, 18 years ago

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 by Andrew Sutherland <andrew@…>, 18 years ago

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 by Nebojša Đorđević <nesh@…>, 18 years ago

Cc: nesh@… added; nesh@… removed

comment:13 by Good gay!, 17 years ago

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 by Good gay!, 17 years ago

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

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

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

comment:15 by Simon G. <dev@…>, 17 years ago

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

spam cleanup on aisle 3.

comment:16 by Jacob, 17 years ago

Resolution: wontfix
Status: newclosed

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

comment:17 by Andrew Badr, 16 years ago

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 by Russell Keith-Magee, 16 years ago

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 by Andrew Badr, 16 years ago

Resolution: wontfix
Status: closedreopened

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

comment:20 by Andrew Badr, 16 years ago

Resolution: wontfix
Status: reopenedclosed

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

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