Hi there This relates to Turbogears, but is really a SA question.
I've customized TG authentication & authorization to use my autloaded tables in Postgres and SqlAlchemy 0.3.3. In my schema, I have User.c.uid, the login name of the users, as a primary key TG uses a User mapper with two distinct columns: User.c.user_id (the primary key) and User.c.user_name (the logname). Since I am an avid fan of meaningful primary keys (and have a legacy db to support) I want to keep things my way, but TG does some user handling that I have to fix. So, to avoid patches to the TG source or useless sub-classing, I'd like to access the same column by any of the three names. I cannot do that with a python property on the mapper because TG should be able to use get_by and friends. I've come up with: assign_mapper(context, User, tbl['users'], properties = { 'user_id': tbl['users'].c.uid, # alias for SqlAlchemyIdentity 'user_name': tbl['users'].c.uid, # alias for SqlAlchemyIdentity 'uid': tbl['users'].c.uid, }) This seems to work (I added the third property to make 'uid' reappear!) , but makes it impossible, for instance, to create new users: In [1]: user = User(uid='xxx') In [2]: session.flush() [...] SQLError: (IntegrityError) null value in column "uid" violates not-null constraint 'INSERT INTO users (uid, nome, cognome, codice_fiscale) VALUES (%(uid)s, %(name)s, %(surname)s)' {'surname': None, 'uid': None, 'name': None} In [3]: user = User(user_id='xxx') In [4]: session.flush() [...] SQLError: (IntegrityError) null value in column "uid" violates not-null constraint 'INSERT INTO users (uid, nome, cognome, codice_fiscale) VALUES (%(uid)s, %(name)s, %(surname)s)' {'surname': None, 'uid': None, 'name': None} I reckon I should probably go ahead and patch TG, but maybe there is a clean way to do what I have in mind? Thank you. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---