#10112: Python Crash with ORM Inheritance
----------------------------------------------------+-----------------------
Reporter: [email protected] | Owner: nobody
Status: closed | Milestone:
Component: Database layer (models, ORM) | Version: 1.0
Resolution: worksforme | Keywords:
Stage: Unreviewed | Has_patch: 0
Needs_docs: 0 | Needs_tests: 0
Needs_better_patch: 0 |
----------------------------------------------------+-----------------------
Changes (by Alex):
* status: new => closed
* resolution: => worksforme
Comment:
This is working fine for me:
{{{
In [1]: from django.db import models
In [2]: class Foo(models.Model):
...: _bar = models.TextField(db_column='bar')
...: bar = property(lambda self: self._bar)
...:
...:
---------------------------------------------------------------------------
IndexError Traceback (most recent call
last)
/home/alex/<ipython console> in <module>()
/usr/lib/python2.5/site-packages/django/db/models/base.pyc in __new__(cls,
name, bases, attrs)
49 # For 'django.contrib.sites.models', this would be
'sites'.
50 model_module = sys.modules[new_class.__module__]
---> 51 kwargs = {"app_label":
model_module.__name__.split('.')[-2]}
52 else:
53 kwargs = {}
IndexError: list index out of range
In [3]: class Foo(models.Model):
_bar = models.TextField(db_column='bar')
bar = property(lambda self: self._bar)
...: class Meta:
...: app_label = ''
...:
...:
In [6]: class Bla(Foo):
...: bar = pro
projects/alexs_language projects/euler property
projects/chatlog projects/hoogstraten
projects/election_sim projects/pinax
...: bar = property(lambda self: "a")
...:
...:
---------------------------------------------------------------------------
IndexError Traceback (most recent call
last)
/home/alex/<ipython console> in <module>()
/usr/lib/python2.5/site-packages/django/db/models/base.pyc in __new__(cls,
name, bases, attrs)
49 # For 'django.contrib.sites.models', this would be
'sites'.
50 model_module = sys.modules[new_class.__module__]
---> 51 kwargs = {"app_label":
model_module.__name__.split('.')[-2]}
52 else:
53 kwargs = {}
IndexError: list index out of range
In [7]: class Bla(Foo):
bar = property(lambda self: "a")
...: class Meta:
...: app_label = ''
...:
...:
In [9]: Foo.bar
Out[9]: <property object at 0x8d2c5cc>
In [10]: Foo().bar
Out[10]: ''
In [11]: Foo(_bar='a').bar
Out[11]: 'a'
In [12]: Bla().bar
Out[12]: 'a'
In [13]: Bla(_bar="f").bar
Out[13]: 'a'
}}}
There's some debugging cruft in there because I was working from the
shell, but it seems to work fine,
--
Ticket URL: <http://code.djangoproject.com/ticket/10112#comment:3>
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
-~----------~----~----~----~------~----~------~--~---