def _get_config(self): registry = getUtility(IRegistry) config = registry.forInterface(IPaypalConfiguration) if config.api_username and config.api_password and \ config.api_signature and config.api_environment: kw = {'API_USERNAME': config.api_username, 'API_PASSWORD': config.api_password, 'API_SIGNATURE': config.api_signature, 'API_ENVIRONMENT': config.api_environment} return PayPalConfig(**kw) else: return None
def __init__(self, config=None, **kwargs): """ Constructor, which passes all config directives to the config class via kwargs. For example: paypal = PayPalInterface(API_USERNAME='******') Optionally, you may pass a 'config' kwarg to provide your own PayPalConfig object. """ if config: # User provided their own PayPalConfig object. self.config = config else: # Take the kwargs and stuff them in a new PayPalConfig object. self.config = PayPalConfig(**kwargs)