[Twisted-Python] xml

Hey everyone, I have been looking all night and I can’t find any examples of using simple xml to write my own xml protocol for a chat server I intend to build. All I want to do is generate XML from commands and send it across the socket and receive it on the other end and unpack it. Any recommendations on what to use and any tutorials or examples on how to do it. I don’t know a whole lot about XML programming, just it’s basic structure. Thanks! -- No virus found in this outgoing message. Checked by AVG Free Edition. Version: 7.5.432 / Virus Database: 268.17.11/652 - Release Date: 1/25/2007 3:32 PM

On Thu, 25 Jan 2007 21:57:32 -0500, Lee Connell <lee.a.connell@gmail.com> wrote:
Rather than developing a new protocol, have you considered using an existing general purpose protocol to accomplish your goals? For example, XMPP is an XML-based protocol which is already implemented in Twisted. You could use it to send messages. Also, why are you interested in XML specifically? Netstrings, AMP, or PB might also be suitable. Almost certainly, at least one of these is suited for the problem you are trying to solve, and it is always beneficial to avoid implementing a new protocol when possible. Jean-Paul

Jean-Paul, Thanks for your input, I looked at them all, AMP looked pretty cool, but that's just something that is enhancing XML-RPC correct? Netstrings looked like a viable solution, but I like XML formatting better. I am not sure if what I originally asked was correct, I am not designing some new protocol, all I am doing is looking for something to wrap up my packets which hold some commands and data, very basic stuff, is that considered writing my own protocol? Anyways, it looks like minidom will do what I want as far as parsing strings and creating DOM's. Thank you! //////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////// Rather than developing a new protocol, have you considered using an existing general purpose protocol to accomplish your goals? For example, XMPP is an XML-based protocol which is already implemented in Twisted. You could use it to send messages. Also, why are you interested in XML specifically? Netstrings, AMP, or PB might also be suitable. Almost certainly, at least one of these is suited for the problem you are trying to solve, and it is always beneficial to avoid implementing a new protocol when possible. Jean-Paul _______________________________________________ Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python -- No virus found in this incoming message. Checked by AVG Free Edition. Version: 7.5.432 / Virus Database: 268.17.11/652 - Release Date: 1/25/2007 3:32 PM -- No virus found in this outgoing message. Checked by AVG Free Edition. Version: 7.5.432 / Virus Database: 268.17.12/653 - Release Date: 1/26/2007 11:11 AM

On 1/27/07, Lee Connell <lee.a.connell@gmail.com> wrote:
No, AMP is not based on XML-RPC at all; it's a custom protocol which offers two-way communications (XML-RPC only supports client->server request/response), and it doesn't use XML in the first place.
Netstrings looked like a viable solution, but I like XML formatting better.
Why do you like XML formatting better? It's waaay more complicated than netstrings, and if your protocol is simple, you shouldn't need something too complicated.
Yes :) -- Christopher Armstrong International Man of Twistery http://radix.twistedmatrix.com/ http://twistedmatrix.com/ http://canonical.com/

Jean Paul, Do you use netstrings? What version of netstrings.py do you use? I'll have another look at it, is this a non-maintained script? As far as XML, I'm just use to it because of web development, that's all. -Lee -----Original Message----- From: twisted-python-bounces@twistedmatrix.com [mailto:twisted-python-bounces@twistedmatrix.com] On Behalf Of Christopher Armstrong Sent: Saturday, January 27, 2007 7:38 PM To: Twisted general discussion Subject: Re: [Twisted-Python] xml On 1/27/07, Lee Connell <lee.a.connell@gmail.com> wrote: that
is enhancing XML-RPC correct?
No, AMP is not based on XML-RPC at all; it's a custom protocol which offers two-way communications (XML-RPC only supports client->server request/response), and it doesn't use XML in the first place.
Netstrings looked like a viable solution, but I like XML formatting better.
Why do you like XML formatting better? It's waaay more complicated than netstrings, and if your protocol is simple, you shouldn't need something too complicated.
Yes :) -- Christopher Armstrong International Man of Twistery http://radix.twistedmatrix.com/ http://twistedmatrix.com/ http://canonical.com/ _______________________________________________ Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python -- No virus found in this incoming message. Checked by AVG Free Edition. Version: 7.5.432 / Virus Database: 268.17.12/653 - Release Date: 1/26/2007 11:11 AM -- No virus found in this outgoing message. Checked by AVG Free Edition. Version: 7.5.432 / Virus Database: 268.17.12/653 - Release Date: 1/26/2007 11:11 AM

But can you use that with your own custom tcp servers? Like a chat server? -----Original Message----- From: twisted-python-bounces@twistedmatrix.com [mailto:twisted-python-bounces@twistedmatrix.com] On Behalf Of George Pauly Sent: Friday, January 26, 2007 8:38 AM To: Twisted general discussion Subject: Re: [Twisted-Python] xml There's an example of twisted.web.xmlrpc in TNPE (the O'Reilly Twisted book). I think you can download the code from the O'Reilly website. -George On Thu, 2007-01-25 at 21:57 -0500, Lee Connell wrote:
_______________________________________________ Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python -- No virus found in this incoming message. Checked by AVG Free Edition. Version: 7.5.432 / Virus Database: 268.17.11/652 - Release Date: 1/25/2007 3:32 PM -- No virus found in this outgoing message. Checked by AVG Free Edition. Version: 7.5.432 / Virus Database: 268.17.12/653 - Release Date: 1/26/2007 11:11 AM

Hi Lee, On Fri, 26 Jan 2007 16:55:43 -0600, Lee Connell <lee.a.connell@gmail.com> wrote:
But can you use that with your own custom tcp servers? Like a chat server?
If it isn't a terrible nuisance, I'd like to ask you to please refrain from top-posting. It makes following a thread harder, and that means you're less likely to get good answers to your questions. Not ragging on you or anything, just making a request :) Regarding twisted.web.xmlrpc: No, you cannot use it with any arbitrary server; that module is specific to http. You could certainly read over the code (it is short) to get an idea of how to implement xmlrpc atop your own tcp server. For certain though, the best thing to look at is twisted.words, since that package is full of chat protocols. The jabber stuff, in particular, should be helpful, since jabber uses a streaming XML protocol. I'd seriously suggest using the jabber stuff, rather than inventing your own protocol. Also, take a look at twisted.words.xish.xmlstream. From the docstring: "The most prominent use of XML Streams is Jabber, but this module is generically usable. See Twisted Words for Jabber specific protocol support." That seems to me to be closest to what you want. Hope this helps, L. Daniel Burr

If it isn't a terrible nuisance, I'd like to ask you to please refrain from top-posting.
L. Daniel Burr, Thanks for your response, I'm looking at twisted.words now. What exactly is top-posting? -Lee -- No virus found in this outgoing message. Checked by AVG Free Edition. Version: 7.5.432 / Virus Database: 268.17.12/653 - Release Date: 1/26/2007 11:11 AM

On Thu, 25 Jan 2007 21:57:32 -0500, Lee Connell <lee.a.connell@gmail.com> wrote:
Rather than developing a new protocol, have you considered using an existing general purpose protocol to accomplish your goals? For example, XMPP is an XML-based protocol which is already implemented in Twisted. You could use it to send messages. Also, why are you interested in XML specifically? Netstrings, AMP, or PB might also be suitable. Almost certainly, at least one of these is suited for the problem you are trying to solve, and it is always beneficial to avoid implementing a new protocol when possible. Jean-Paul

Jean-Paul, Thanks for your input, I looked at them all, AMP looked pretty cool, but that's just something that is enhancing XML-RPC correct? Netstrings looked like a viable solution, but I like XML formatting better. I am not sure if what I originally asked was correct, I am not designing some new protocol, all I am doing is looking for something to wrap up my packets which hold some commands and data, very basic stuff, is that considered writing my own protocol? Anyways, it looks like minidom will do what I want as far as parsing strings and creating DOM's. Thank you! //////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////// Rather than developing a new protocol, have you considered using an existing general purpose protocol to accomplish your goals? For example, XMPP is an XML-based protocol which is already implemented in Twisted. You could use it to send messages. Also, why are you interested in XML specifically? Netstrings, AMP, or PB might also be suitable. Almost certainly, at least one of these is suited for the problem you are trying to solve, and it is always beneficial to avoid implementing a new protocol when possible. Jean-Paul _______________________________________________ Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python -- No virus found in this incoming message. Checked by AVG Free Edition. Version: 7.5.432 / Virus Database: 268.17.11/652 - Release Date: 1/25/2007 3:32 PM -- No virus found in this outgoing message. Checked by AVG Free Edition. Version: 7.5.432 / Virus Database: 268.17.12/653 - Release Date: 1/26/2007 11:11 AM

On 1/27/07, Lee Connell <lee.a.connell@gmail.com> wrote:
No, AMP is not based on XML-RPC at all; it's a custom protocol which offers two-way communications (XML-RPC only supports client->server request/response), and it doesn't use XML in the first place.
Netstrings looked like a viable solution, but I like XML formatting better.
Why do you like XML formatting better? It's waaay more complicated than netstrings, and if your protocol is simple, you shouldn't need something too complicated.
Yes :) -- Christopher Armstrong International Man of Twistery http://radix.twistedmatrix.com/ http://twistedmatrix.com/ http://canonical.com/

Jean Paul, Do you use netstrings? What version of netstrings.py do you use? I'll have another look at it, is this a non-maintained script? As far as XML, I'm just use to it because of web development, that's all. -Lee -----Original Message----- From: twisted-python-bounces@twistedmatrix.com [mailto:twisted-python-bounces@twistedmatrix.com] On Behalf Of Christopher Armstrong Sent: Saturday, January 27, 2007 7:38 PM To: Twisted general discussion Subject: Re: [Twisted-Python] xml On 1/27/07, Lee Connell <lee.a.connell@gmail.com> wrote: that
is enhancing XML-RPC correct?
No, AMP is not based on XML-RPC at all; it's a custom protocol which offers two-way communications (XML-RPC only supports client->server request/response), and it doesn't use XML in the first place.
Netstrings looked like a viable solution, but I like XML formatting better.
Why do you like XML formatting better? It's waaay more complicated than netstrings, and if your protocol is simple, you shouldn't need something too complicated.
Yes :) -- Christopher Armstrong International Man of Twistery http://radix.twistedmatrix.com/ http://twistedmatrix.com/ http://canonical.com/ _______________________________________________ Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python -- No virus found in this incoming message. Checked by AVG Free Edition. Version: 7.5.432 / Virus Database: 268.17.12/653 - Release Date: 1/26/2007 11:11 AM -- No virus found in this outgoing message. Checked by AVG Free Edition. Version: 7.5.432 / Virus Database: 268.17.12/653 - Release Date: 1/26/2007 11:11 AM

But can you use that with your own custom tcp servers? Like a chat server? -----Original Message----- From: twisted-python-bounces@twistedmatrix.com [mailto:twisted-python-bounces@twistedmatrix.com] On Behalf Of George Pauly Sent: Friday, January 26, 2007 8:38 AM To: Twisted general discussion Subject: Re: [Twisted-Python] xml There's an example of twisted.web.xmlrpc in TNPE (the O'Reilly Twisted book). I think you can download the code from the O'Reilly website. -George On Thu, 2007-01-25 at 21:57 -0500, Lee Connell wrote:
_______________________________________________ Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python -- No virus found in this incoming message. Checked by AVG Free Edition. Version: 7.5.432 / Virus Database: 268.17.11/652 - Release Date: 1/25/2007 3:32 PM -- No virus found in this outgoing message. Checked by AVG Free Edition. Version: 7.5.432 / Virus Database: 268.17.12/653 - Release Date: 1/26/2007 11:11 AM

Hi Lee, On Fri, 26 Jan 2007 16:55:43 -0600, Lee Connell <lee.a.connell@gmail.com> wrote:
But can you use that with your own custom tcp servers? Like a chat server?
If it isn't a terrible nuisance, I'd like to ask you to please refrain from top-posting. It makes following a thread harder, and that means you're less likely to get good answers to your questions. Not ragging on you or anything, just making a request :) Regarding twisted.web.xmlrpc: No, you cannot use it with any arbitrary server; that module is specific to http. You could certainly read over the code (it is short) to get an idea of how to implement xmlrpc atop your own tcp server. For certain though, the best thing to look at is twisted.words, since that package is full of chat protocols. The jabber stuff, in particular, should be helpful, since jabber uses a streaming XML protocol. I'd seriously suggest using the jabber stuff, rather than inventing your own protocol. Also, take a look at twisted.words.xish.xmlstream. From the docstring: "The most prominent use of XML Streams is Jabber, but this module is generically usable. See Twisted Words for Jabber specific protocol support." That seems to me to be closest to what you want. Hope this helps, L. Daniel Burr

If it isn't a terrible nuisance, I'd like to ask you to please refrain from top-posting.
L. Daniel Burr, Thanks for your response, I'm looking at twisted.words now. What exactly is top-posting? -Lee -- No virus found in this outgoing message. Checked by AVG Free Edition. Version: 7.5.432 / Virus Database: 268.17.12/653 - Release Date: 1/26/2007 11:11 AM
participants (5)
-
Christopher Armstrong
-
George Pauly
-
Jean-Paul Calderone
-
L. Daniel Burr
-
Lee Connell