0

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.

Ronaldo Nascimento
  • 1,571
  • 3
  • 21
  • 40
  • I dont know why I could not find this before, but this is a duplicate of: https://stackoverflow.com/a/41823430/142798 – Ronaldo Nascimento Apr 05 '19 at 14:52
  • Possible duplicate of [Declare model before create connection in ming](https://stackoverflow.com/questions/41807329/declare-model-before-create-connection-in-ming) – Ronaldo Nascimento Apr 05 '19 at 14:52

0 Answers0