> 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.

I still didn't understand your intent. An example will help.

Anyway, you can do something like this:

def myprocessor(handler):
    if web.config.debug: # or if is_test_mode:
        return handler()
    else:
        initialize_my_db()
        return handler()

app.add_processor(my_processor)

Does it make sense?

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to