def connect(self, receiver, sender=None, weak=True, dispatch_uid=None): receiver_name = '.'.join( [receiver.__class__.__module__, receiver.__class__.__name__]) if receiver_name != self.allowed_receiver: raise AccessForbidden(u"%s is not allowed to connect" % receiver_name) Signal.connect(self, receiver, sender, weak, dispatch_uid)
def sdk_client(self): try: request = get_request() # 调用sdk方法获取sdk client return self.load_sdk_class("shortcuts", "get_client_by_request")(request) except Exception: if settings.RUN_MODE != "DEVELOP": if self.common_args: return self.load_sdk_class("client", "ComponentClient")( app_code=settings.APP_CODE, app_secret=settings.SECRET_KEY, common_args=self.common_args) else: raise AccessForbidden( "sdk can only be called through the Web request") else: # develop mode # 根据RUN_VER获得get_component_client_common_args函数 get_component_client_common_args = import_string( "blueapps.utils.sites.{platform}." "get_component_client_common_args".format( platform=settings.RUN_VER)) return self.load_sdk_class("client", "ComponentClient")( app_code=settings.APP_CODE, app_secret=settings.SECRET_KEY, common_args=get_component_client_common_args())