#3148: Add getters and setters to model fields
-----------------------------+----------------------------------------------
Reporter: [EMAIL PROTECTED] | Owner: telenieko
Status: assigned | Component: Database wrapper
Version: SVN | Resolution:
Keywords: MESSAGE | Stage: Accepted
Has_patch: 1 | Needs_docs: 0
Needs_tests: 0 | Needs_better_patch: 0
-----------------------------+----------------------------------------------
Comment (by SmileyChris):
Reviewing your patch:
1. Using the reserved word "`property`" sounds like it'll get you in to
trouble. In fact, I can't see how the patch would even work since you try
to `setattr` to `property(getter, setter, delter, docter))` but `property`
would be defined as the tuple! How about using `property_` or
`use_property` or something.
2. why do you need to keep the `property` tuple around? (i.e.
`self.property = property`)
3. instead of your __add__ magic, how about something simpler, like:
{{{
#!python
if len(use_property) < 2
# getter and setter are both required.
raise ValueError("You must specify at least a getter and a setter
method with use_property")
# Create a property on ``cls`` with the methods given.
setattr(cls, self.name, property(*use_property))
}}}
--
Ticket URL: <http://code.djangoproject.com/ticket/3148#comment:10>
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
-~----------~----~----~----~------~----~------~--~---