Como puedo usar una variable de una clase en un método, estoy levantando un servicio de SMPP
Código:
def Active(idEventSms): x=SMPP(idEventSms) x.run() y=x.message() reactor.run() return y class SMPP(object): def __init__(self,idEventSms,config=None): if config is None: logging.basicConfig(level=logging.DEBUG) self.idEventSms=int(idEventSms) self.Event=None host='host' port=0000 username='user' password='pass' self.smpp=None config = SMPPClientConfig(host=host, port=port, username=username, password=password) self.config = config @defer.inlineCallbacks def run(self): try: self.smpp = yield SMPPClientTransceiver(self.config,self.handleMsg).connectAndBind() yield self.smpp.getDisconnectedDeferred() except Exception, e: print "ERROR: %s" % str(e) finally: reactor.stop() def handleMsg(self, smpp, pdu): """ NOTE: you can return a Deferred here """ print "Received pdu %s" % pdu def message(self): """ NOTE: you can return a Deferred here """ submit_pdu = SubmitSM( #service_type, #source_addr_ton=SOURCE_ADDR_TON, #source_addr_npi, source_addr=ESME_NUM, #dest_addr_ton=DEST_ADDR_TON, #dest_addr_npi=DEST_ADDR_NPI, destination_addr=self.phoneNumber, esm_class=EsmClass(EsmClassMode.STORE_AND_FORWARD, EsmClassType.SMSC_DELIVERY_RECEIPT), protocol_id=0, #priority_flag, #schedule_delivery_time, #validity_period, registered_delivery=RegisteredDelivery(RegisteredDeliveryReceipt.SMSC_DELIVERY_RECEIPT_REQUESTED), replace_if_present_flag=ReplaceIfPresentFlag.DO_NOT_REPLACE, data_coding=DataCoding(DataCodingScheme.DEFAULT, DataCodingDefault.SMSC_DEFAULT_ALPHABET), sm_default_msg_id=self.idEventSms, short_message=self.bodySms) a,f=self.smpp.sendEvent(str(self.idEventSms),self.idSmsFriend) print a,f self.smpp.sendDataRequest(submit_pdu) self.smpp.getDisconnectedDeferred() return self.smpp
Pero necesito que retorne el valor de smpp y retorna otra cosa que no es no quiero que al llamar el self.smpp, funcione desde cualquier parte fuera de la clase.
Gracias de antemano.