On Thu, Jun 3, 2010 at 12:10 PM, Ben Firshman <b...@firshman.co.uk> wrote: > > On 3 Jun 2010, at 17:45, Carl Meyer wrote: > >> On Jun 2, 6:20 pm, Ben Firshman <b...@firshman.co.uk> wrote: >>> Yeah, this idea came up at the sprints, but it's a little too magic for my >>> tastes. >> >> I dunno... is __new__ really more magic than having a __call__ method >> that magically copies the instance you call it on? That certainly >> breaks my expectations. >> >> Django doesn't shy away from "magic" in other areas where it makes for >> a usable API. The things that happen to model and form fields >> certainly violate the initial expectations of a Python programmer; but >> it turns out that most people are happy to write readable models and >> don't care what's happening under the hood, and those who do care can >> learn a little something about metaclasses. Seems to me that __new__ >> is a relatively beautiful solution to a thorny problem: it lets people >> use class views in all the same ways they use function views while >> maintaining thread-safety, it maintains the "callable that returns >> HttpResponse" contract, and most people won't ever see or care about >> the "magic" that makes it work. >> >> +1 for __new__. > > One advantage of using __call__ over __new__ is passing arguments to > __init__. That's handy for lazily configuring views: > > (r'', DetailView(queryset=Thing.objects.all()) > > Ben > > -- > You received this message because you are subscribed to the Google Groups > "Django developers" group. > To post to this group, send email to django-develop...@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. > >
I thought we said we really wanted to encourage using subclassing to solve these problems (providing many types of args in urls.py can cause problems). 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-develop...@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.