mixing the metaclasses is difficult, and mixing of standard Python ABCs is 
not a use case we've tested - ideally we'd provide some simplified system 
to make it easy to integrate ABCs with declarative.

It would be much simpler if you stick with straight declarative for now, 
which supports the concept of "abstract bases" in a more rudimental way 
(via the __abstract__ flag), as well as mixins and custom base classes.

the docs have lots of examples on this: 

http://docs.sqlalchemy.org/en/rel_0_8/orm/extensions/declarative.html#mixin-and-custom-base-classes

http://docs.sqlalchemy.org/en/rel_0_8/orm/extensions/declarative.html#abstract


On Thursday, December 13, 2012 10:29:17 AM UTC-5, somewhatofftheway wrote:
>
> Hi, I'd appreciate any thoughts on this; it seems like there are ways to 
> do much more complex versions, so I guess I'm just missing a simple way to 
> achieve it:
>
> I have some polymorphic classes which inherit from a single parent class. 
> The parent has the table mapped on it, and also defines a fair bit of 
> functionality for itself.
>
> The child classes don't have any different fields, but do need to define a 
> lot of their own functionality. Because there are a lot of methods 
> involved, I'm interested in making the parent class abstract so that child 
> classes are forced to define certain functions.
>
> I had hoped to use Abstract Base Classes (
> http://www.doughellmann.com/PyMOTW/abc/) to do this, but I can't just 
> declare the parent class as an ABC as it inherits from Base.
>
>
> To use the traditional example:
>
>   
>   class Employee(Base):
>     __tablename__ = 'employee'
>     __metaclass__ = abc.ABCMeta
>
>     __mapper_args__ = {        
>              'polymorphic_on':type,
>    }
>
>    @abc.abstractmethod
>    def calculate_bonus(self):
>        """Each child class *must* implement this"""
>
>  
>
>
>     class Manager(Employee):
>          __mapper_args__ = {
>         'polymorphic_identity':'manager'
>         }
>
>
> The above will fail due to metaclass conflict, as you would expect. 
>
> I've looked at a lot of ways of doing this, but none of them seemed right.
>
> Thanks for any help,
> Benjamin
>
>
>
>
>                                                                           
>                                                                             
>    
>  ~                                                                       
>                                                                             
>                      
> ~                                                                         
>                                                                             
>                    
> ~                                                                         
>                                                                             
>                    
> ~                                                                         
>                                                                             
>                    
> ~                                                                         
>                                                                             
>                    
> ~                                                                         
>                                                                             
>                    
> ~                                                                         
>                                                                             
>                    
> ~                                                                         
>                                                                             
>                    
> ~                                                                         
>                                                                             
>                    
> ~                                                                         
>                                                                             
>                    
> ~                                                                         
>                                                                             
>                    
> ~                                                                         
>                                                                             
>                    
> ~                                                                         
>                                                                             
>                    
> ~                                                                         
>                                                                             
>                    
> ~                                                                         
>                                                                             
>                    
> ~                                                                         
>                                                                             
>                    
> ~                                                                         
>                                                                             
>                    
> ~                                                                         
>                                                                             
>                    
> sqlamail.txt                                                               
>                                                                             
> 1,1            All
> "sqlamail.txt" 13L, 640C
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/sqlalchemy/-/EtJO2fGiox4J.
To post to this group, send email to sqlalchemy@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.

Reply via email to