Code

Changes between Version 56 and Version 57 of ModelInheritance


Ignore:
Timestamp:
04/30/08 02:35:50 (6 years ago)
Author:
ramiro
Comment:

Update with current status

Legend:

Unmodified
Added
Removed
Modified
  • ModelInheritance

    v56 v57  
    11= Model Inheritance = 
    22 
    3 '''As of 2008, both SQLObject and SQLAlchemy have sound and tested implementations of model inheritance. Whoever is or starts working on this should try to reuse their efforts.''' 
     3== Current Status == 
     4 
     5This was implemented into the queryset-refactoring branch that was merged into trunk in changeset r7477. See QuerysetRefactorBranch. 
     6 
     7''What follows in this page are opinions, notes and ramblings of some individuals regarding this topic collected since Aug. 2005.'' 
     8 
     9== Misc. content == 
     10 
     11As of 2008, both SQLObject and SQLAlchemy have sound and tested implementations of model inheritance. Whoever is or starts working on this should try to reuse their efforts. 
    412 
    513This is a proposal for how subclassing should work in Django. There are a lot of details to get right, so this proposal should be very specific and detailed. Most of the ideas here come from the thread linked below: 
     
    1119[http://groups.google.com/group/django-developers/browse_frm/thread/9a9a2cfacce690d/dfcd5a71ba523534?q=Just+a+few+vague+notes&rnum=1#dfcd5a71ba523534 django-developers: Change subclassing syntax] 
    1220 
    13 == Current Status == 
    14  
    15 This was implemented into the queryset-refactoring branch in changeset r7126, there are still several bugs with it according to the commit notes. 
    16  
    17 == Subclassing == 
     21=== Subclassing === 
    1822 
    1923For subclassing, there are 3 main issues: 
     
    3943 
    4044 
    41 === 1. Modeling parent relations in SQL? === 
     45==== 1. Modeling parent relations in SQL? ==== 
    4246 
    4347The general consesus seems to be this: 
     
    9094 
    9195 
    92 === 2. Modeling joins in SQL === 
     96==== 2. Modeling joins in SQL ==== 
    9397 
    9498When we want a list of {{{ItalianRestaurant}}}s, we obviously need all the fields from myapp_restaurant and myapp_place as well. This could be accomplished by inner joins. It would look something like this: 
     
    221225 
    222226 
    223 === 3. API === 
     227==== 3. API ==== 
    224228 
    225229The following API examples assume we have created these objects: 
     
    245249 
    246250 
    247 == Change the current usage of subclassing == 
     251=== Change the current usage of subclassing === 
    248252 
    249253{{{ 
     
    267271}}} 
    268272 
    269 == Ramblings on Magic Removal Subclassing from the Pycon Sprint == 
     273=== Ramblings on Magic Removal Subclassing from the Pycon Sprint === 
    270274 
    271275Consider the following variation on the above restaurant example: 
     
    316320 
    317321 
    318 == Mixins == 
     322=== Mixins === 
     323 
    319324here are two scenarios where mixins would be useful (to me). 
    320325