snake211985 Posted March 1, 2012 Report Share Posted March 1, 2012 Estimados: Tengo un problema en python ya que no puedo recorrer una lista aqui dejo el codigo Objeto DTO.. class DTOCHAT: def __init__(self, pos,send,response): self.pos = pos self.send = send self.response = response def borrarChat(self): self._del_() def _del_(self): print('eliminar') aqui se recorre el XML..... que crea una lista de tipo objeto............ import xml.dom.minidomfrom com.raw.dto.DTOChat import DTOCHATclass LeerXml(): def buscaXMLTag(self,xmlFile): xmlTag = str('CHAT') resultList = [] try: dom = xml.dom.minidom.parse(xmlFile) print("dom", dom); conference=dom.getElementsByTagName('CHAT') for node in conference: name=node.getAttribute('name') print (name) alist=node.getElementsByTagName('COM') print(alist) for a in alist: pos = a.getAttribute('pos') print ("pos",pos) send = a.getAttribute('send') print ("send",send) response = a.getAttribute('response') print ("response",response) dtoChat=DTOCHAT(pos,send,response); #dtoChat.pos = pos #dtoChat.send = send #dtoChat.response = response resultList.append(dtoChat) len(resultList) print ("resultList", len(resultList)) dtoChat.borrarChat() except: print ('xxx Path del fichero: ',self.xmlFile) return resultList print(resultList) aqui esta el problema: class Cliente(Thread): def __init__(self, archivoxml,socket_cliente, datos_cliente): # LLamada al constructor padre, para que se inicialice de forma # correcta la clase Thread. Thread.__init__(self) print("estoy aqui") # Guardamos los parametros recibidos. self.socket = socket_cliente print("self.socket",self.socket) #self.socket = socket_cliente self.datos = datos_cliente print("self.datos",self.datos) self.archivoxml= archivoxml leerxml = LeerXml.buscaXMLTag(self, archivoxml) # leerxml.__getitem__(str('pos')) #resultXML = leerxml# at1 = leerxml.__getitem__('pos')# print(at1) print("leerXML", len(leerxml)) run(self,leerxml) # Bucle para atender al cliente. def run(self,leerxml): # Bucle indefinido hasta que el cliente envie "adios" print('iniciando cliente'); # count = 0 # ObjDTOChat = DTOCHAT() send = ""; passwd = ""; regex = "[.][*]"; #print('pos',leerxml.getAttribute('pos')) for a in leerxml: //////problema aqui ya que no se puede recorrer los atributos del objeto DTOCHAT.. print('a',a)) mi pregunta es como puedo recorrer la lista que contiene el objeto y rescatar los datos del atributo.. Link to comment Share on other sites More sharing options...
AshWilliams Posted March 8, 2012 Report Share Posted March 8, 2012 Te dejo esta info sobre sockets en python, te puede servir: http://wiki.python.org/moin/HowTo/Sockets Saludos :krider: Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now