Index: elixir/trunk/elixir/entity.py
===================================================================
--- elixir/trunk/elixir/entity.py (revision 279)
+++ elixir/trunk/elixir/entity.py (revision 284)
@@ -82,9 +82,10 @@
         self.builders = []
 
+        self.is_base = is_base(entity)
         self.parent = None
         self.children = []
 
         for base in entity.__bases__:
-            if isinstance(base, EntityMeta) and not base.__bases__[0] is object:
+            if isinstance(base, EntityMeta) and not is_base(base):
                 if self.parent:
                     raise Exception('%s entity inherits from several entities,'
@@ -252,5 +253,8 @@
                     self.parent._descriptor.add_constraint(constraint)
                 return
-            elif self.inheritance == 'concrete':
+            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 columns from parent table
                 for col in self.parent._descriptor.columns:
@@ -438,5 +442,5 @@
             check_duplicate = not self.allowcoloverride
         
-        if check_duplicate and self.get_column(col.key) is not None:
+        if check_duplicate and self.get_column(col.key, False) is not None:
             raise Exception("Column '%s' already exist in '%s' ! " % 
                             (col.key, self.entity.__name__))
@@ -481,5 +485,5 @@
         self.mapper_options['extension'] = extensions
 
-    def get_column(self, key):
+    def get_column(self, key, check_missing=True):
         "need to support both the case where the table is already setup or not"
         #TODO: support SA table/autoloaded entity
@@ -487,4 +491,7 @@
             if col.key == key:
                 return col
+        if check_missing:
+            raise Exception("No column named '%s' found in the table of the "
+                            "'%s' entity!" % (key, self.entity.__name__))
         return None
 
@@ -531,4 +538,7 @@
             return self.entity.table.columns
         else:
+            #FIXME: depending on the type of inheritance, we should also 
+            # return the parent entity's columns (for example for order_by 
+            # using a column defined in the parent.
             return self._columns
     columns = property(columns)
@@ -581,16 +591,29 @@
         return getattr(owner, self.attrname)
 
+def is_base(cls):
+    """
+    Scan bases classes to see if any is an instance of EntityMeta. If we
+    don't find any, it means the current entity is a base class (like 
+    the 'Entity' class).
+    """
+    for base in cls.__bases__:
+        if isinstance(base, EntityMeta):
+            return False
+    return True
 
 class EntityMeta(type):
     """
     Entity meta class. 
-    You should only use this if you want to define your own base class for your
-    entities (ie you don't want to use the provided 'Entity' class).
+    You should only use it directly if you want to define your own base class 
+    for your entities (ie you don't want to use the provided 'Entity' class).
     """
     _entities = {}
 
     def __init__(cls, name, bases, dict_):
-        # only process subclasses of Entity, not Entity itself
-        if bases[0] is object:
+        # Only process further subclasses of the base classes (Entity et al.),
+        # not the base classes themselves. We don't want the base entities to 
+        # be registered in an entity collection, nor to have a table name and 
+        # so on. 
+        if is_base(cls):
             return
 
@@ -621,5 +644,6 @@
             prop.attach(cls, name)
 
-        # process mutators. Needed before setup_proxy for metadata
+        # Process mutators. Needed before _install_autosetup_triggers so that
+        # we know of the metadata
         process_mutators(cls)
 
@@ -710,5 +734,5 @@
     '''Setup all entities in the list passed as argument'''
 
-    for entity in elixir.entities:
+    for entity in entities:
         if entity._descriptor.autosetup:
             _cleanup_autosetup_triggers(entity)
@@ -783,5 +807,5 @@
     '''
     __metaclass__ = EntityMeta
-
+    
     def __init__(self, **kwargs):
         for key, value in kwargs.items():
