Oleg Broytmann a écrit : > On Thu, Mar 22, 2007 at 05:22:33PM +0100, Luper Rouch wrote: > >> I tried to use a custom style class, but it does not seem to be >> involved in the ForeignKey name construction. >> > > Please show a test program that triggers the problem with a style. > > Oleg. > Ok I found the answer to my question while trying to explain my problem :-) To customize ForeignKey naming you have to reimplement instanceAttrToIDAttr and instanceIDAttrToAttr in your style class. Here is an example :
from sqlobject import * class MyStyle(MixedCaseUnderscoreStyle): def instanceAttrToIDAttr(self, attr): return attr def instanceIDAttrToAttr(self, attr): return attr class Foo(SQLObject): pass class Bar(SQLObject): class sqlmeta: style = MyStyle() fooId = ForeignKey("Foo") if __name__ == "__main__": sqlhub.processConnection = connectionForURI("postgres://localhost/test") Foo.createTable() Bar.createTable() This way Bar.fooId corresponds to bar.foo_id in the database ... Thanks ! Luper Rouch ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys-and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ sqlobject-discuss mailing list sqlobject-discuss@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss