hi there, folks:
I'd really like to release 0.7.0 but I would like it to be at least a
little bit tested before I do so. Could those of you with CVS trees check
everything out and see if it performs as advertised? Deeper bugs than
that will have to wait for the next release, but I'd at least like to know
if it works for someone other than me.
______ __ __ _____ _ _
| ____ | \_/ |_____] |_____|
|_____| |_____ | | | |
@ t w i s t e d m a t r i x . c o m
I have an xml file in my application,
I have created an element using
Example goes like this.........
and i appeneded it by using append() method.
But how i can reflect this change to my xml file?
and one more thing is i want to create element with some other parameters....
<abc m=" " n=" ">
and i have m and n values as strings with me.
can anybody help me to create this element and write it to the existing xml file
as a child of an existing element?
Thanks in advance..
Forgot the famous last words? Access your message archive online at http://in.messenger.yahoo.com/webmessengerpromo.php
On 18 May 2004, the following message was posted to this mailinglist:
Jp Calderone exarkun at divmod.com wrote:
>Daniel Newton wrote:
> I have a simple XML-PRC server similar to the example below:
> from twisted.web import xmlrpc, server
> class Example(xmlrpc.XMLRPC):
> """An example object to be published."""
> def xmlrpc_add(self, a, b):
> """Return sum of arguments."""
> return a + b
> if __name__ == '__main__':
> from twisted.internet import reactor
> r = Example()
> reactor.listenTCP(7080, server.Site(r))
> I want to be able to get the address of the client that calls the
> method can anyone help me with this?
This solution didn't work because 'transport' isn't a property of the
I'm currently in the process of changing from a customized
SimpleXMLRPCServer to a twisted XMLRPC server solution and I need to
insert the client IP into the attributes passed to the called xmlrpc
method. Anyone who knows the answer and is willing to share the info?
I have a sample XMPP client with the following structure:
from twisted.words.protocols.jabber import client, jid
from twisted.internet import reactor
factory = client.basicClientFactory(myJid, myPasswd)
It works well, I can connect to the XMPP server. But I would appreciate
if some one could give me some hints on what's required to get the
client to connect using a secure SSL link.
First let me introduce a piece of software I have written using
Twisted: it's called dfd_keeper, and is a BSD/pf port of a generic
concept I invented called the dynamic firewall daemon.
If you like the concept, please promote the idea; I think it's neat
but there hasn't exactly been a groundswell of interest in it.
In essence, it allows you to netcat or telnet to the daemon process
and issue text-like commands that alter your firewall rules. You can
think of it as a "shell" for the firewall, and it can do neat things
like create firewall rules that expire automatically after a period of
time and so on.
The problem I'm having is this; I upgraded my firewall from OpenBSD
4.2 or so to OpenBSD 4.5, and now I'm working with newer versions of
all the software including Twisted.
The program works fine normally, and can run in the background, but if I
invoke a daemonize() routine that turns it into a network daemon, it
refuses to serve incoming TCP connections. Actually the TCP connection
is made, but the software never responds to it.
Specifically, my twisted.internet.protocol.Factory instance is created,
but buildProtocol is never called.
Before I dive deeply into debugging the software, I thought I'd ask if
anyone knew off the top of their head any reason why Twisted might not
act the same if it was daemonized (no controlling terminal, no
stdin/out/err, forked as a background process).
Obama Nation | My emails do not have attachments; it's a digital signature
that your mail program doesn't understand. | http://www.subspacefield.org/~travis/
If you are a spammer, please email john(a)subspacefield.org to get blacklisted.
I was thinking it would be nice to have a Twisted interest group meetup at
EuroPython (June 30 - July 2) http://www.europython.eu
Would people be interested in attending? Does someone more qualified want
to organize it? Are any Twisted developers planning to be at EuroPython?
The submissions page http://www.europython.eu/submission/ has a category
for Interest Group Meeting or Discussion. I'm thinking more along the lines
of the former - that it would be nice to be better connected to other
Twisted programmers in Europe, to put a face to some of the names on the
mailing list / IRC, etc.
On 01:23 am, asb.bush(a)gmail.com wrote:
>I have just started to look at the Twisted framework and would like to
>to use for a new project I am working on. Not being very familiar with
>framework and fairly new to Python in general I would like to ask a
>design/architecture question. (I have written similar applications in
>would prefer to start this in the right direction and not write Python
Thanks for asking!
I apologize for the delay in my answer. I started writing up a simple
example (attached) but was discouraged to find that it was 100 lines
long and required too much explaining.
Then I started documenting it and explaining every line but that was a
very long, tedious message. So, it doesn't have much in the way of
explanation; I hope you will find it useful regardless.
>The application has the following model:
>Many clients connect to the Application and prefer to leave the
>open. They will send messages across this connection. They will
>get a message back at some point later, they do not wait for a response
>(async). The clients are already coded (legacy) and just need to send
>proprietary protocol to the new Application (written using Twisted).
This is *almost* a FAQ. At least, you may find this to be a useful
>The Twisted application will take the data from the clients and do some
>transformation on it then send the message on to another server (3rd
>This connection to "another" server must be a single connection, not
>connection per client. This connection should also be persistent and
>opened/closed for each client message sent. Ideally if the 3rd party
>is down then I would also not accept client connections as the messages
>time sensitive and should not be stored and forwarded. At some point
>part will send a message back and the Application will route it back to
>original source. Basically request/reply pattern.
The example that I've attached does basically this. Run it and then run
'telnet localhost 4322', and type some lines; you will see that they are
transformed and echoed back to you, both by the proxy and by the
protocol being proxied.
At a high level, the answer to your question is so simple that it's hard
to express. Basically, you just need to have all the relevant objects
having references to each other, and calling methods to achieve the
desired effect. The less magic, the better.
More precisely, you need an object responsible for managing your
outgoing connections to your legacy server, so that it can handle
disconnection and reconnection, queueing messages and so on. Then you
need your proxy server factory to hold a reference to that object, so
that it can create references from each proxy server protocol connection
object to the connection manager.
This is related to another recent thread - you can see my message in
that thread here:
>I have been reading through the archives and the twisted docs and have
>looked over the Hex-dump port-forwarding recipe but not found anything
>explains how to use twisted for this model. Hex-dump is close but
>opens/closes the connection to the server on each client connection.
I'm not sure why hex-dump port-forwarding is particularly relevant to
this example. Is it just because this is an application that connects
from one host to another?
>I am thinking that there will be two Factories [and two protocols: 1)
>clients and 2) for 3rd party]. I am not sure how to best establish
>listening factory and the client to 3rd party factory. Once they are
>established what is the preferred way in Twisted to pass a message from
>protocol to another?
This part of your question is almost exactly the FAQ I mentioned above
:). To reiterate that answer, you just need to have references between
objects, and call methods on the objects you want to do stuff.
If you have a client connection object, just get a reference to that
from the relevant server connection object and call methods on the
client object to emit messages on the client protocol, handling any
responses appropriately. Deferreds can help with that latter part.
It is always better if you can establish that reference as simply as
possible; for example, by passing parameters to the __init__ of various
classes. Again, for reasons that have nothing to do with Twisted
specifically, it's a bad idea to try to establish these references by
having global variables floating around.
Here's a very very simple example of the "good way" to propagate some
data to protocol instances that need it:
def __init__(self, data):
self.data = data
def __init__(self, data):
self.data = data
def buildProtocol(self, addr):
reactor.listenTCP(8765, MyFactory("some data"))
and here's a simple example of a really bad way (don't do this!):
self.bleh = bleh
bleh = "some data"
f = Factory()
f.protocol = MyProtocol
Even in C, I'm pretty sure it's better style to pass structures to
functions than to abuse piles of local variables :). I only illustrate
this bad style here because it seems to be a common antipattern. The
Protocol class itself doesn't take any parameters to __init__, and
Twisted's users don't always realize that protocols and factories and so
on are just regular objects, with no special rules; they just get
methods called on them by the reactor.
>Any pointers or sample code that you can offer is greatly appreciated.
>would really like to cook this in Twisted and not go back to the C way.
Based on what you've said so far, I think you're basically on the right
track. Good luck!
I have an issue where the reactor calls the callback from a different
thread than the one the reactor is running in.
The usecase is as follows;
We are running tests using PyFit (Fitnesse), and where some of the
tests depends on receiving SNMP traps in the background. So at the
start we start a trap deamon defined as
class TrapDeamon(Thread, netsnmp.Session)
We use the pynetsnmp.twistedsnmp package and has a run() method that
looks like this
In the callback from the reactor, we get the pdu of the trap which is
then sent into a trap buffer. On the PyFit side of things, we execute
some commands, and at some points we need a confirmation from a trap
before we can continue. This is done by waiting on a queue
(Queue.Queue). The trap buffer has a register over queues and awaited
trap OID's, and when the correct one is added to the buffer from the
reactor callback, it is put onto the queue, the test rejoice, and
However, I noticed that fairly often (say every 3rd wait), the wait
timed out even though I had seen the trap on wireshark. So I improved
the logging, and noticed that in the cases where the wait timed out,
the reactor callback for the trap I waited for happened in the main
thread (at least main thread id is reported by python logging), and
thus did not appear until immediately after the wait had failed and
unblocked. Most of the trap callbacks (both before and after these
misses) happens in the correct (reactor) thread though.
What can cause this and how may I debug it? AFAIK, PyFit does not use
twisted or threading at all, and we only have two simple background
threads our selves in addition to the one running the trap deamon.
Lars Ivar Igesund
I just subscribed to this list, after viewing tons of documents about
twisted, factories, and all the like.
Here is the situation.
I am trying to design a bridge between twisted.web and
I have read a lot about using factories, and communicating with a
central "program class" like in the finger tutorial.
However, I can not figure out how to communicate between two running
Here's an example:
User connects to web server.
Irc client connects to irc server
User clicks on search link, and enters query.
A command, along with that query, is sent to irc server via irc client.
Response is returned, processed, and sent to the page that is the result
of submiting that form.
Process continues until user clicks log out, where in the irc client
Any help anyone can give me is greatly appreciated.