Advertisement
Guest User

Untitled

a guest
Oct 28th, 2017
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1. I'm trying to write my first custom application with a small 'extension' system in the sense that every extension can provide application-level services (class instances for particular purposes, such as entity repositories, or renderers) for re-use by other extensions that depend on them. The way I'm used to doing this with PHP is key/value service containers that are passed along everywhere and can be used by factories to extract those services by their machine names (keys). This means you have to know about the services' machine names, and introduces indirection by code having to pass on or accept the container if they're somehow involved with class factories.
  2.  
  3. Instead of passing around such a container (in whatever shape or form), would it make sense and be Pythonic to execute every new application instance in a context of its own, setting a global 'stack' variable to the app instance/container, making it accessible to any factory code that needs it (removing the code needed to inject the container)? When the application stops, the context would reset the global variable to its previous value.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement