Toshio -- when you say "multi-file models" do you mean that you define
your model classes in numerous files, and then import all these files
into a single model/__init__.py file?

I use something like that and I find it frustrating when model A wants
to call a method on model B but it can not because the two modules can
not import each other.

So, this is what I do: at the end of my model/__init__.py file,  after
I import everything, I loop through every imported class and then add
a class attribute "g" which is a reference to the globals()
dictionary.

g = globals()
for c in A, B, C, ... # every imported model.
    c.g = g

Then, inside my A class, I can get a reference to B like this:

class A(...):

    def some_method(self):
         B = self.g['B']

This works fine, but I would love to find a less "creative" solution.

An alternate approach is to pass B in as a parameter, but that gets
tiresome when I need a six-table join.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to