#3148: Add getters and setters to model fields
----------------------------------------+-----------------------------------
Reporter: [EMAIL PROTECTED] | Owner: telenieko
Status: assigned | Milestone:
Component: Database wrapper | Version: SVN
Resolution: | Keywords:
Stage: Ready for checkin | Has_patch: 1
Needs_docs: 0 | Needs_tests: 0
Needs_better_patch: 0 |
----------------------------------------+-----------------------------------
Comment (by Gulopine):
Doing some quick looking at this (I'll admit, I haven't applied it yet), I
came up with a 7-line utility function that handles everything the patch
does, but without touching core at all. If there's interest, I can post it
at djangosnippets, but I think there's something else to consider.
While the latest patch is a considerable cleanup from the original patch,
I think [http://groups.google.com/group/django-
developers/msg/c98281ddafe97aa3 one of the original author's
considerations] has been lost in translation. Again, I haven't applied it,
but it looks like it does exactly what my little utility function does,
and mine certainly suffers from the double-setter problem he describes.
Malcolm's [source:django/trunk/django/db/models/fields/subclassing.py
field subclassing work] does a good job of avoiding this, but it uses a
descriptor, which would interfere with the property, unless a new
descriptor is made that takes the double-setter issue *and* the property
stuff into account. Ultimately, I think it's a matter of providing the
simple, common case, like Malcolm did, and expecting those who need more
to know what they need. I don't know if that's enough for everybody, but
that's why I was working on a non-core option for this. I'd rather people
do a little hunting on the problem they have before they just pick a
"solution" that happens to be in core and get confused why it doesn't work
the way it should.
Of course, one other thing `SubfieldBase` takes into account is
serialization. Again, I haven't applied the patch or tested it out (I'm
heck-deep in other stuff at the moment), but I'm guessing there are going
to be some surprises, since I've run into a few things in the past when an
object's `__dict__` didn't line up with what some properties were
advertising. I'd certainly at least want to see that looked at by someone
who's passionate about this patch.
--
Ticket URL: <http://code.djangoproject.com/ticket/3148#comment:19>
Django Code <http://code.djangoproject.com/>
The web framework for perfectionists with deadlines
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---