On Thu, Jul 30, 2009 at 8:58 AM, Dj Gilcrease<digitalx...@gmail.com> wrote:
>
> On Thu, Jul 30, 2009 at 5:55 AM, Russell
> Keith-Magee<freakboy3...@gmail.com> wrote:
>> Of course, Alex and I may have missed an obvious alternative solution
>> - or a use case that isn't solved by either approach. Any feedback or
>> alternative approaches we may have missed are most welcome.
>
>
> It's been a while since I did anything with custom fields,
> django.contrib.contenttypes.generic.GenericRelation has a reference to
> the model it is attached to that is created in def
> contribute_to_class(self, cls, name):. I am going to assume that in
> the multi-db code the Model has a reference to the connection it is
> supposed to use, so why not add the reference to model to the Field
> class, then any time you need connection info you get it from the
> parent model?
>
> class Field(object):
>    ...
>    def contribute_to_class(self, cls, name):
>        self.model = cls
>        ...
>
> >
>

Dj,

That won't work, models aren't bound to a specific connection, they
can be used with anyone, as determined at run time.

Russ:  My primary concern with adding a new method is that it will
signficantly complicate the implementation, particularly it pollutes
the implementation, rather than putting the onus on calling code,
which I've found makes it a very clean transition.  In total there are
under a dozen places within Django that call these methods, and
eventual deprecation/removal would be fairly easy.  I haven't actually
found a usecase for user code calling into get_db_prep_* or db_type.
I should also note that I've found a total of 2-3 instances of user
code callign these methods on Django field classes in all of google
code search, indeed far fewer than the number of places these methods
are implemented.  So I do still believe that my original proposal is
the least invasive, and reasonably backwards compatible (it's worth
remembering just be the nature of this discussing we're already
talking about a veyr minority of users who have custom field classes
with these methods).

Alex

-- 
"I disapprove of what you say, but I will defend to the death your
right to say it." -- Voltaire
"The people's good is the highest law." -- Cicero
"Code can always be simpler than you think, but never as simple as you
want" -- Me

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to django-developers@googlegroups.com
To unsubscribe from this group, send email to 
django-developers+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to