def __init__(self): super(AuthMiddleware, self).__init__() self.log = logger.get_log(__name__) auth = getattr(settings, 'HUBSPOT_MARKETPLACE_AUTH', {}) self.secret = auth.get('secret_key') if not self.secret: self.log.warn(self.__class__.DEACTIVATION_NOTICE) raise MiddlewareNotUsed
def __init__(self): super(DebugModeLoggingMiddleware, self).__init__() self.log = logger.get_log(__name__) if not getattr(settings, "DEBUG", False): self.log.info("DebugModeLoggingMiddleware has been turned off for all requests cuz we're not in debug mode") raise MiddlewareNotUsed if not getattr(settings, "DEBUG_MODE_LOGGING", True): self.log.info("DebugModeLoggingMiddleware has been explicitly turned off for all requests") raise MiddlewareNotUsed self.log.info("DebugModeLoggingMiddleware has been activated")
def __init__(self): super(ErrorGogglesMiddleware,self).__init__() self.log = logger.get_log(__name__) debug_mode = getattr(settings, 'DEBUG', False) if not debug_mode: self.log.info('ErrorGogglesMiddleware has been turned off for all requests because we are not in DEBUG mode') raise MiddlewareNotUsed self.head_re = re.compile(r'<head>(.*?)</head>',re.DOTALL) self.body_re = re.compile(r'<body>(.*?)</body>',re.DOTALL) self.style_re = re.compile(r'<style type="text/css">(.*?)</style>', re.DOTALL) self.script_re = re.compile(r'<script type="text/javascript">(.*?)</script>', re.DOTALL) self.reset_styles = open(os.path.join(os.path.dirname(__file__),'error_goggles_reset.css')).read() self.log.info('ErrorGogglesMiddleware has been activated')
def __init__(self): super(DebugModeLoggingMiddleware, self).__init__() self.log = logger.get_log(__name__) if not getattr(settings, 'DEBUG', False): self.log.info( 'DebugModeLoggingMiddleware has been turned off for all requests cuz we\'re not in debug mode' ) raise MiddlewareNotUsed if not getattr(settings, 'DEBUG_MODE_LOGGING', True): self.log.info( 'DebugModeLoggingMiddleware has been explicitly turned off for all requests' ) raise MiddlewareNotUsed self.log.info('DebugModeLoggingMiddleware has been activated')
def __init__(self): super(MockMiddleware, self).__init__() mock = getattr(settings, 'HUBSPOT_MARKETPLACE_MOCK', {}) mock_safety = getattr(settings, 'HUBSPOT_MARKETPLACE_MOCK_SAFETY', None) auth = getattr(settings, 'HUBSPOT_MARKETPLACE_AUTH', {}) secret = auth.get('secret_key') self.log = logger.get_log(__name__) if not mock or mock and not secret or mock_safety and not os.environ.get( mock_safety): self.log.info( 'MockMiddleware has been turned off for all requests') raise MiddlewareNotUsed payload = 'payload' digest = hmac.new(secret, payload, hashlib.sha1).digest() self.signature = '.'.join( [self.base64_url_encode_for_real(s) for s in [digest, payload]]) self.slug = mock.get('slug') if not self.slug: raise KeyError("Missing slug definition in MockMiddleware") self.prefix_path_re = re.compile('/market/(\d+)/canvas/%s' % self.slug) self.body_re = re.compile(r'<body>(.*?)</body>', re.DOTALL) self.head_re = re.compile(r'<hs:head>(.*?)</hs:head>', re.DOTALL) self.link_re = re.compile(r'<hs:link (.*?)/?>') self.script_re = re.compile(r'<hs:script(.*?)>(.*?)</hs:script>', re.DOTALL) self.title_re = re.compile(r'<hs:title(.*?)>(.*?)</hs:title>') self.form_re = re.compile(r'(<form\s.*?)action="(/.*?)"') # keeping this kicking around cuz we'll likely uncomment when marketplace fixes # how this works # self.anchor_re = re.compile(r'(<a\s.*?)href="(/.*?)"') path = os.path.join(os.path.dirname(__file__), 'mock.html') self.wrapper = open(path).read() self.build_static_params(mock) self.log.info('HubSpot Marketplace Mock Canvas Middleware Activated')
def __init__(self): super(MockMiddleware,self).__init__() mock = getattr(settings, 'HUBSPOT_MARKETPLACE_MOCK', {}) mock_safety = getattr(settings, 'HUBSPOT_MARKETPLACE_MOCK_SAFETY', None) auth = getattr(settings, 'HUBSPOT_MARKETPLACE_AUTH', {}) secret = auth.get('secret_key') self.log = logger.get_log(__name__) if not mock or mock and not secret or mock_safety and not os.environ.get(mock_safety): self.log.info( 'MockMiddleware has been turned off for all requests') raise MiddlewareNotUsed payload = 'payload' digest = hmac.new(secret, payload, hashlib.sha1).digest() self.signature = '.'.join( [self.base64_url_encode_for_real(s) for s in [digest, payload]]) self.slug = mock.get('slug') if not self.slug: raise KeyError("Missing slug definition in MockMiddleware") self.prefix_path_re = re.compile('/market/(\d+)/canvas/%s'%self.slug) self.body_re = re.compile(r'<body>(.*?)</body>',re.DOTALL) self.head_re = re.compile(r'<hs:head>(.*?)</hs:head>',re.DOTALL) self.link_re = re.compile(r'<hs:link (.*?)/?>') self.script_re = re.compile(r'<hs:script(.*?)>(.*?)</hs:script>', re.DOTALL) self.title_re = re.compile(r'<hs:title(.*?)>(.*?)</hs:title>') self.form_re = re.compile(r'(<form\s.*?)action="(/.*?)"') # keeping this kicking around cuz we'll likely uncomment when marketplace fixes # how this works # self.anchor_re = re.compile(r'(<a\s.*?)href="(/.*?)"') path = os.path.join(os.path.dirname(__file__),'mock.html') self.wrapper = open(path).read() self.build_static_params(mock) self.log.info('HubSpot Marketplace Mock Canvas Middleware Activated')