On Wednesday 27 May 2009, Mark Ramm wrote: > You don't need to define your tables inside init_model itself, but > init_model will be called after the metadata is setup and engine > defined, but before your app is loaded, so it's an obvious place from > which to manage table reflection. > > You can call other functions or class methods from init_model, so you > can split things up as you choose. >
I think I should refine the question: The problem with the above is that the classes one defines are local to the init_model function. Thus a "from xxx.model import someclass" throws an error. I can't import the classes at the end of __init__.py as it would normally be done, because as you pointed out, nothing is initialized and the table isn't reflected yet, so referencing it is impossible at that point. Basically all I want to do is reflect the tables and map a class to the reflected table which then at one point can simply be imported from xxx.model In TG1 this was easy - reflect the table at the top of model.py and then just use it in some other module where the according class and mapping is set up. Maybe this is a basic python scope question, but still the answer eludes me. Uwe --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "TurboGears" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/turbogears?hl=en -~----------~----~----~----~------~----~------~--~---

