On Mon, Sep 29, 2008 at 5:01 PM, Joril <[EMAIL PROTECTED]> wrote: > > Hi everyone! > I'm new to SQLAlchemy and I'm using version 0.5rc1.. > I need every entity class to have a few common fields, so I tried > writing an "abstract" base class, declarative-style, that every other > entity class would subclass. So for example: > > --- > from sqlalchemy.ext.declarative import declarative_base > from sqlalchemy import Column, String, DateTime, Integer > > ORMBase = declarative_base() > > class BaseObject(ORMBase): > id = Column(Integer, primary_key=True) > creation_time = Column(DateTime) > modify_time = Column(DateTime) > > class TestEntity(BaseObject): > value = Column(String) > --- > > But SQLAlchemy complains that > sqlalchemy.exc.ArgumentError: Mapper 'Mapper|BaseObject|None' does not > have a mapped_table specified. (Are you using the return value of > table.create()? It no longer has a return value.) > > Is there a way to tell SQLAlchemy to treat BaseObject like a non- > mapped-class? I tried using ORMBase as mixin to TestEntity (so > BaseObject extends object and TestEntity extends BaseObject and > ORMBase), but now I get a > > sqlalchemy.exc.ArgumentError: Mapper Mapper|TestEntity|tests could not > assemble any primary key columns for mapped table 'tests' > > so I guess that maybe I'm going down the wrong road.. Am I doing > something that Declarative doesn't like? :) Should I try Elixir > instead?
I don't know whether this is currently possible with Declarative or not. In the case it isn't, patching Declarative should be quite easy (but I don't know if such a patch would be accepted or not). If you don't want to go down that route, Elixir does support that pattern. -- Gaƫtan de Menten http://openhex.org --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalchemy@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~----------~----~----~----~------~----~------~--~---