j2labs / brubeck

Asynchronous web and messaging
http://brubeck.io
511 stars 66 forks source link

Assign `kwargs` key, value to brubeck #99

Open kracekumar opened 11 years ago

kracekumar commented 11 years ago

Brubeck() takes **kwargs but key, value isn't stored in brubeck object, storing the key, value is useful for third party libraries.

Example:

config = {
    'msg_conn': WSGIConnection(),
    'template_loader': load_jinja2_env('./../demos/templates'),
    'cookie_secret': 'OMGSOOOOOSECRET',
    'assets': {
        'directory': './../assets',
        'debug': True,
        }
}

# Instantiate app instance
b_app = Brubeck(**config)
app = SimpleURL(b_app)
from brubeck_utils.assets import Environment
assets = Environment(app)

right now I need to access brubeck configuration values as well, one way to get around this is. assets = Environment(app, config['assests']) or assets = Environment(config).

Currently brubeck doesn't have config object which can used by third party modules.

There are two ways to fix:

  1. Add config dict which stores all configuration details passed during object creation, so that third party libraries can access it. EG: I can place my CAPTCHA_SECRET, OAUTH_SECRET in config dict or python file.
  2. Assign kwargs key, value during object creation.
for key, value in kwargs.items():
      setattr(self, key, value)

Method 1 is preferred.

I will be happy to submit the patch, if accepted.