What I do is to instantiate them in a separate common module (settings.py) and call it from the others.
from settings import render, auth # etc. On 5 mayo, 05:30, Ole Trenner <[email protected]> wrote: > Hi Anand, > > Anand Chitipothu wrote: > > what do you mean by dependency injection? can you give an example? > > In my handlers I need access to a db service, an authentication manager > and so on. These helpers are partly interconnected and partly > longliving, that's why I don't want to spread their instantiation across > the code but rather concentrate it in one place. Plus I actually don't > want to instantiate them from the handler methods at all, because during > testing I'd prefer having the possibility to use simplified or mocked > versions of these helpers. > That's why I'd like to have the possibility to somehow influence the > instantiation phase of my handlers. The easiest approach were > constructor arguments, but there are others. > Currently I'm helping myself with monkey patching and things like that, > but they're just bad style. > > Cheers, > Ole. > > -- > Ole Trenner > <[email protected]> --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "web.py" 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/webpy?hl=en -~----------~----~----~----~------~----~------~--~---
