1. fanstatic
  2. fanstatic
  3. fanstatic
  4. Issues
Issue #6 open

Easy way to get needed from WSGI environ

Jan-Wijbrand Kolman
created an issue

We should also provide a method in Fanstatic that allows the user to easily get the currently needed resources from a WSGI environ. This is to support a shared-nothing architecture.

Comments (2)

  1. Jan-Wijbrand Kolman reporter
    • changed status to open

    Should this function also return a DummyNeededResources() instance whenever the WSGI environ does not have a needed resources object yet?

    If so, would it be an idea to modify the current ``get_needed()`` to optionally accepts an environ argument. Something like::

    def get_needed(environ=None):
        if environ is not None:
            ctxt = environ
        else:
            ctxt = thread_local_needed_data.__dict__
        needed = ctxt.get(NEEDED)
        if needed is None:
            # When no NeededResources have been set up, we inject a
            # DummyNeededResources object here.
            # We do this in order not to tax other code that may need()
            # a resource here and there but has not set up NeededResources.
            return DummyNeededResources()
        return needed
    
  2. Jan-Wijbrand Kolman reporter

    My suggestion would imply to also make the init_needed() and clear_needed() and possibly even the Resource.need() methods to optionally accepts a environ argument. Hmmm, not so sure this will make for a nice API.

    What about merely introducing a get_needed_from_environ(environ) function in fanstatic?

  3. Log in to comment