How do I pass the session object of a ThreadLocalODMSession to a class defined in another python file?

208 Views Asked by At

I hope I can explain this issue correctly.

I want to define the ThreadLocalODMSession object in one python file, and have defined several other files with the classes that represent the mongo collection. But the sample source code for ming always shows the ThreadLocalODMSession object as a local variable, that sets the session variable in the __mongometa__ subclass of the collection definition class.

In the example, the definition of WikiPage is in the same script as the definition of the ThreadLocalODMSession (called session) object, and get passed in the __mongometa__ definition.

class WikiPage(MappedClass):
class __mongometa__:
    session = session
    name = 'wiki_page'

I want to be able to pass the session object into the __init__ method of the WikiPage, and then have the __mongometa__ subclass set its copy of session on creation.

0

There are 0 best solutions below