Django: app level variables

A possible solution is to implement a custom Django middleware, as described in https://docs.djangoproject.com/ja/1.9/topics/http/middleware/. You could initialize the HTTP connection pool in the middleware’s __init__ method, which is only called once at the first request. Then, start the HTTP request during process_request and on process_response check it has finished (or wait for it) and append … Read more

How to avoid global variables

Global variables should be avoided because they inhibit code reuse. Multiple widgets/applications can nicely live within the same main loop. This allows you to abstract what you now think of as a single GUI into a library that creates such GUI on request, so that (for instance) a single launcher can launch multiple top-level GUIs … Read more

how to declare and define global variables in order to access them from all headers/source files properly

In header file only do namespace gi { extern MapInformation mapInf; }; In CPP file provide the actual definition. namespace gi { MapInformation mapInf; }; It will work as you intend. If you are using the MapInformation across dynamic link library boundaries you might have to link against the library that includes the definition cpp … Read more