#3148: Add getters and setters to model fields
---------------------------------------------------+------------------------
Reporter: [email protected] | Owner: Gulopine
Status: new | Milestone:
Component: Database layer (models, ORM) | Version: SVN
Resolution: | Keywords:
Stage: Accepted | Has_patch: 1
Needs_docs: 0 | Needs_tests: 0
Needs_better_patch: 1 |
---------------------------------------------------+------------------------
Comment (by Alex):
Some feedback:
a) A decorator should always return a callable, in this case it should
return the original function (as Gulopine sugested), since the alternative
leaves None on the class, which is really awkward IMO.
b) As Gulopine suggested I think the better approach is to make the Field
object itself the descriptor when getter/setter/deleter are provided, not
a property object.
c) This should be handled by Field.contribute_to_class, not the Metaclass.
d) I'd like to see significantly more extensive tests, particularly with
things like:
* Providing only a subset of the available options.
* Providing a getter/setter with fields that have their own descriptor
(FileField and the RelatedFields). This I suspect may require a large
refactor of related.py, as Gulopine may have already found :)
--
Ticket URL: <http://code.djangoproject.com/ticket/3148#comment:28>
Django <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.