Index: /elixir/trunk/AUTHORS
===================================================================
--- /elixir/trunk/AUTHORS (revision 327)
+++ /elixir/trunk/AUTHORS (revision 327)
@@ -0,0 +1,19 @@
+Initial developers
+- Daniel Haus
+- GaÃ«tan de Menten
+- Jonathan LaCour
+
+Website design and maintenance
+- Daniel Haus
+
+Contributors (listed alphabetically)
+- Alexandre da Silva
+- Alice McGregor
+- Ants Aasma
+- Ben Bangert
+- Jason R. Coombs
+- Neil Blakey-Milner
+- Paul Johnston
+- Remi Jolin
+- Robin Munn
+- some anonymous contributions I couldn't trace to someone in particular
Index: /elixir/trunk/CHANGES
===================================================================
--- /elixir/trunk/CHANGES (revision 325)
+++ /elixir/trunk/CHANGES (revision 327)
@@ -17,4 +17,12 @@
 - Fixed ManyToOne relationships using 'key' kwarg in their column_kwargs
   (patch by Jason R. Coombs) 
+- Fixed inheritance with autoloaded entities: when using autoload, we 
+  shouldn't try to add columns to the table (closes tickets #41 and #43).
+- Fixed ColumnProperty to work with latest version of SQLAlchemy (O.4.5 and
+  later)
+
+Misc:
+- Added AUTHORS list. If you are missing from this list, don't hesitate to
+  contact me.
 
 0.5.2 - 2008-03-28
Index: /elixir/trunk/elixir/entity.py
===================================================================
--- /elixir/trunk/elixir/entity.py (revision 324)
+++ /elixir/trunk/elixir/entity.py (revision 327)
@@ -261,62 +261,58 @@
         if self.autoload != only_autoloaded:
             return
-        
-        if self.parent:
-            if self.inheritance == 'single':
-                # we know the parent is setup before the child
-                self.entity.table = self.parent.table 
-
-                # re-add the entity columns to the parent entity so that they
-                # are added to the parent's table (whether the parent's table
-                # is already setup or not).
-                for col in self.columns:
-                    self.parent._descriptor.add_column(col)
-                for constraint in self.constraints:
-                    self.parent._descriptor.add_constraint(constraint)
-                return
-            elif self.inheritance == 'concrete': 
-                #TODO: we should also copy columns from the parent table if the
-                # parent is a base entity (whatever the inheritance type -> elif
-                # will need to be changed)
-
-                # Copy all non-primary key columns from parent table (primary 
-                # key columns have already been copied earlier).
-                for col in self.parent._descriptor.columns:
-                    if not col.primary_key:
-                        self.add_column(col.copy())
-
-                #FIXME: use the public equivalent of _get_colspec when available 
-                for con in self.parent._descriptor.constraints:
-                    self.add_constraint(
-                        ForeignKeyConstraint(
-                            [c.key for c in con.columns],
-                            [e._get_colspec() for e in con.elements],
-                            name=con.name, #TODO: modify it
-                            onupdate=con.onupdate, ondelete=con.ondelete,
-                            use_alter=con.use_alter))
-
-        if self.polymorphic and \
-           self.inheritance in ('single', 'multi') and \
-           self.children and not self.parent:
-            self.add_column(Column(self.polymorphic, 
-                                   options.POLYMORPHIC_COL_TYPE))
-
-        if self.version_id_col:
-            if not isinstance(self.version_id_col, basestring):
-                self.version_id_col = options.DEFAULT_VERSION_ID_COL_NAME
-            self.add_column(Column(self.version_id_col, Integer))
-
-        # create list of columns and constraints
+
+        kwargs = self.table_options
         if self.autoload:
             args = self.table_args
+            kwargs['autoload'] = True
         else:
+            if self.parent:
+                if self.inheritance == 'single':
+                    # we know the parent is setup before the child
+                    self.entity.table = self.parent.table 
+
+                    # re-add the entity columns to the parent entity so that they
+                    # are added to the parent's table (whether the parent's table
+                    # is already setup or not).
+                    for col in self.columns:
+                        self.parent._descriptor.add_column(col)
+                    for constraint in self.constraints:
+                        self.parent._descriptor.add_constraint(constraint)
+                    return
+                elif self.inheritance == 'concrete': 
+                    #TODO: we should also copy columns from the parent table 
+                    # if the parent is a base (abstract?) entity (whatever the
+                    # inheritance type -> elif will need to be changed)
+
+                    # Copy all non-primary key columns from parent table 
+                    # (primary key columns have already been copied earlier).
+                    for col in self.parent._descriptor.columns:
+                        if not col.primary_key:
+                            self.add_column(col.copy())
+
+                    #FIXME: use the public equivalent of _get_colspec when 
+                    #available 
+                    for con in self.parent._descriptor.constraints:
+                        self.add_constraint(
+                            ForeignKeyConstraint(
+                                [c.key for c in con.columns],
+                                [e._get_colspec() for e in con.elements],
+                                name=con.name, #TODO: modify it
+                                onupdate=con.onupdate, ondelete=con.ondelete,
+                                use_alter=con.use_alter))
+
+            if self.polymorphic and \
+               self.inheritance in ('single', 'multi') and \
+               self.children and not self.parent:
+                self.add_column(Column(self.polymorphic, 
+                                       options.POLYMORPHIC_COL_TYPE))
+
+            if self.version_id_col:
+                if not isinstance(self.version_id_col, basestring):
+                    self.version_id_col = options.DEFAULT_VERSION_ID_COL_NAME
+                self.add_column(Column(self.version_id_col, Integer))
+
             args = self.columns + self.constraints + self.table_args
         
-        # specify options
-        kwargs = self.table_options
-
-        if self.autoload:
-            kwargs['autoload'] = True
-
         self.entity.table = Table(self.tablename, self.metadata, 
                                   *args, **kwargs)
Index: /elixir/trunk/elixir/properties.py
===================================================================
--- /elixir/trunk/elixir/properties.py (revision 303)
+++ /elixir/trunk/elixir/properties.py (revision 327)
@@ -178,5 +178,5 @@
 
     def evaluate_property(self, prop):
-        return column_property(prop.label(self.name))
+        return column_property(prop.label(None))
 
 
Index: /elixir/trunk/tests/test_autoload.py
===================================================================
--- /elixir/trunk/tests/test_autoload.py (revision 313)
+++ /elixir/trunk/tests/test_autoload.py (revision 327)
@@ -5,8 +5,19 @@
 from sqlalchemy import Table, Column, ForeignKey, MetaData
 from elixir import *
+from elixir import options
 import elixir
 
+def setup_entity_raise(cls):
+    try:
+        setup_entities([cls])
+    except Exception, e:
+        pass
+    else:
+        assert False, "Exception did not occur setting up %s" % cls.__name__
+
+# ------
+
 def setup():
-    # First create the tables (it would be better to use an external db)
+    # First create the tables
     meta = MetaData('sqlite:///')
 
@@ -39,7 +50,5 @@
     global Person, Animal, Category
 
-    #TODO: split these into individual classes for each test. It's best to wait
-    # till we can define several classes in a method with reference between them
-    # without having to make them global.
+    #TODO: split these into individual classes for each test.
     class Person(Entity):
         father = ManyToOne('Person')
@@ -73,5 +82,5 @@
     elixir.options_defaults.update(dict(autoload=False, shortnames=False))
 
-#-----------
+# -----------
 
 class TestAutoload(object):
@@ -83,5 +92,5 @@
         session.clear()
     
-    def test_autoload(self):
+    def test_simple(self):
         snowball = Animal(name="Snowball II")
         slh = Animal(name="Santa's Little Helper")
@@ -100,5 +109,5 @@
         assert homer == slh.owner
 
-    def test_autoload_selfref(self):
+    def test_selfref(self):
         grampa = Person(name="Abe")
         homer = Person(name="Homer")
@@ -120,5 +129,5 @@
         assert p is Person.get_by(name="Lisa").father
 
-    def test_autoload_m2m(self):
+    def test_m2m(self):
         stupid = Category(name="Stupid")
         simpson = Category(name="Simpson")
@@ -145,5 +154,5 @@
         assert c in grampa.categories
 
-    def test_autoload_m2m_selfref(self):
+    def test_m2m_selfref(self):
         barney = Person(name="Barney")
         homer = Person(name="Homer", appreciate=[barney])
@@ -158,19 +167,5 @@
         assert homer in barney.isappreciatedby
 
-
-def setup_entity_raise(cls):
-    try:
-        setup_entities([cls])
-    except Exception, e:
-        pass
-    else:
-        assert False, "Exception did not occur setting up %s" % cls.__name__
-
-class TestAutoloadOverrideColumn(object):
-    def setup(self):
-        create_all()
-
-    def teardown(self):
-        drop_all()
+    # overrides tests
 
     def test_override_pk_fails(self):
@@ -203,3 +198,51 @@
         assert isinstance(Animal.table.columns['name'].type, String)
 
-
+    # ----------------
+
+    def test_nopk(self):
+        metadata.bind = 'sqlite:///'
+
+        local_meta = MetaData(metadata.bind)
+
+        table = Table('a', local_meta,
+            Column('id', Integer),
+            Column('name', String(32)))
+        
+        local_meta.create_all()
+
+        class A(Entity):
+            using_options(tablename='a', autoload=True)
+            using_mapper_options(primary_key=['id'])
+
+        setup_all()
+
+        a1 = A(id=1, name="a1")
+
+        session.flush()
+        session.clear()
+
+        res = A.query.all()
+
+        assert len(res) == 1
+        assert res[0].name == "a1"
+
+    def test_inheritance(self):
+        metadata.bind = 'sqlite:///'
+
+        local_meta = MetaData(metadata.bind)
+
+        table = Table('father', local_meta,
+            Column('id', Integer, primary_key=True),
+            Column('row_type', options.POLYMORPHIC_COL_TYPE))
+
+        local_meta.create_all()
+
+        options_defaults["autoload"] = True
+
+        class Father(Entity):
+            using_options(tablename='father')
+
+        class Son(Father): 
+            pass
+
+        setup_all()
Index: /elixir/trunk/tests/test_properties.py
===================================================================
--- /elixir/trunk/tests/test_properties.py (revision 313)
+++ /elixir/trunk/tests/test_properties.py (revision 327)
@@ -74,5 +74,5 @@
  
             score = ColumnProperty(lambda c: 
-                                   select([func.sum(User.score)],
+                                   select([func.avg(User.score)],
                                           User.category_id == c.id
                                          ).as_scalar())
@@ -92,5 +92,5 @@
 
         category = Category.query.one()
-#        assert category.score == 85 # doesn't work for now
+        assert category.score == 85
         for user in category.users:
             assert user.score == sum([tag.score for tag in user.tags])
Index: /ixir/trunk/tests/test_autoload_nopk.py
===================================================================
--- /elixir/trunk/tests/test_autoload_nopk.py (revision 271)
+++  (revision )
@@ -1,41 +1,0 @@
-"""
-    simple test case
-"""
-
-from sqlalchemy import Table, Column, MetaData
-from elixir import *
-
-def setup():
-    metadata.bind = 'sqlite:///'
-
-def teardown():
-    cleanup_all()
-
-#-----------
-
-class TestAutoload(object):
-    def test_pk(self):
-        local_meta = MetaData(metadata.bind)
-
-        person_table = Table('person', local_meta,
-            Column('id', Integer),
-            Column('name', String(32)))
-        
-        local_meta.create_all()
-
-        class Person(Entity):
-            using_options(tablename='person', autoload=True)
-            using_mapper_options(primary_key=['id'])
-
-        setup_all()
-
-        barney = Person(id=1, name="Barney")
-
-        session.flush()
-        session.clear()
-
-        persons = Person.query.all()
-
-        assert len(persons) == 1
-        assert persons[0].name == "Barney"
-
