#2363: [patch] Tighten subclass check at top of
db.models.base.ModelBase.__new__.
--------------------------------------+-------------------------------------
Reporter: [EMAIL PROTECTED] | Owner: mtredinnick
Status: reopened | Component: Core framework
Version: | Resolution:
Keywords: | Stage: Unreviewed
Has_patch: 1 | Needs_docs: 0
Needs_tests: 0 | Needs_better_patch: 0
--------------------------------------+-------------------------------------
Comment (by [EMAIL PROTECTED]):
Replying to [comment:8 [EMAIL PROTECTED]:
> I'm kinda leery of adding the module check: if the name check is
hackish, wouldn't it be more of the same? I concede that the only cases
that would defeat it are pathological.
I agree, it's just what the first patch meant to say: "Is this Model
''which is defined elsewhere in this module''?"
It's arguably more explicit then catching the NameError, but the comment
solves that.
> I'm sorry about not getting a patch up yesterday; (a tapas bar viciously
leaped on me, I barely escaped with my life.) I've got an (untested) one
here just to show what I meant a few comments ago. (I can't run the new
test (or the others) atm, but maybe Chris would give it a crack?)
Tapas bars can be very verocious. I have one living around the corner,
which makes my residence in it's hunting grounds. ;)
The patch tested out fine. I've merged the code with my testcode. Maybe
you can add some of your mix-in code to the test too?
I've never written a mix-in in Python, but could this be a start for a
test?
{{{
#!python
class PurrMixin():
"""Working Cars"""
def make_noise(self):
return "VROOOM"
class RacketMixin():
"""Car Wrecks"""
def make_noise(self):
return "RRRRRR crack BANG RRRR"
class HummingMixin():
"""Fancy Hybrid Cars"""
running_motor = None
def make_noise(self):
if self.running_motor == 'Combustion':
return "VROOOM"
else:
return "mmmmmm"
}}}
--
Ticket URL: <http://code.djangoproject.com/ticket/2363#comment:9>
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
-~----------~----~----~----~------~----~------~--~---