I've got multiple input buttons and their view is the same logic. The logic
is delete some data on a button press, then rerender the page with the
updated data. The data it will remove depends on the unique ID of the button
pressed. When the web page is rerendered the view gets called for each
button with the same http request, so the deletion logic will be evaluated
for each button, even though it should be evaluated for just the button that
was pressed. I don't like that. I want to clear request.args so the behavior
will be as if there was only one http event, corresponding to a single
button press. I tried "request.args.clear()", but that doesn't seem to have
the expected effect.
What's worse is when I click the browser's reload button, request.args still
has the last http request that occurred. In other words, if I click my
delete button the page will be rerendered with updated data, then if I click
the browser's reload it will try to delete more data as if I had hit on of
my delete buttons again. Can anyone help me with this problem?
Twisted-Python mailing list
I have a form with a submit button. I want to send my data from the form in
a web page to an other web page. Also, I want to check if the data is
I'm new to twisted, so I need some help
MSN Messenger : discutez en direct avec vos amis !
I really need help.
I want to make a form dynamically. I don't want to use FormProcess and I do
not understand very well how it works. If someone have documentation on
forms (not the one on twisted matrix), it will be appreciated.
MSN Messenger : discutez en direct avec vos amis !
I need a front-end to a complex of Zope systems. The front-end listens on
an address/port and examines incoming http transactions, and, based upon
http headers and other information, connects to one or another of the Zope
systems. The underlying approach is straightforward -- a Listener waits
for a http transaction, it spawns a receiver which gathers the message,
decides what to do, spawns a sender to the destination. When the sender
responds, the process is reversed.
I currently use an adaptation of Antony Baxter's pydirector to do the job.
I use his asynchat version, but have found that it leaks file descriptors
in my application. I've not tried the twisted version.
So I thought I'd try to craft a tailored, light-weight version using
the twisted framework. I see how to manage things when everything works,
but what if one or another of the endpoints fails? How do I get
everything cleaned up?
What is the general opinion on having a standard way to adapt
RemoteReferences to specific interfaces which basically just
wraps callRemote for each respective method?
The reason i'm bringing this up is I can imagine various
use-cases for wanting to treat remote objects and local objects
as semantically equivalent. For example, I may be employing
the observer pattern for a simple system to separate UI components
from data components. Currently if I wish to have both remote and
local observers interoperate I would have to either store them
in separate data structures and treat each differently when
sending notifications, or, I could store them in a single
data structure and use appropriate type-checking to dispatch the
calls. IMHO both of these solutions are relatively ugly.
Whether or not there are sufficient use-cases for a standard twisted
way to do this is another story, so i'm wondering what the views of
people are on this subject. Certainly one could just register their own
adapter for RemoteReference in each case, but the code to do this is rather
ugly and for those that _do_ have to deal with such cases I think it would
be nicer to have a simple, standard way of doing it,
I've written a function that outlines the functionality I think it should
provide which is included below; while this implementation is rather ugly
i'm more worried about the idea rather than how it would eventually be
implemented if someone decides this is worth having.
Of course, there are certain constraints, such as the method wrappers
having no way of knowing if the remote object actually implements the
desired interface or not, but I don't see this as a problem for something
that already requires string based dispatch. I guess you could say this
proposal is somewhat similar to java's 'stub' approach, only it doesn't
force it :-).
def add(x,y): pass
def mul(x,y): pass
def div(x,y): pass
def sub(x,y): pass
def callRemote(self, name, *args, **kw): print 'calling %s with %s %s' % (name, args, kw)
# this would likely put put in RemoteReference
# to provide context
def adaptTo(self, interface):
# obtain all interface methods
methods = interface.__dict__
for base in interface.__bases__:
for attrib,val in base.__dict__.iteritems():
if not methods.has_key(attrib) and isinstance(val, types.FunctionType):
methods[attrib] = base.__dict__[attrib]
def __init__(self, original): self.original = original
for m in methods:
exec "def %s(self, *args, **kw): return self.original.callRemote('%s', *args, **kw)" % (m,m)
a = adaptTo(Foo(), Interface2)
I am writing a chat socket server and need to make sure that there are no
conflicts when writing to other attached clients. I am concerned that when
the server receives lots of messages from many socket connections, several
sockets may encounter write contention.
Is there a queue for the write method of a socket?
Should one expect errors in this regard?
Does the Twisted architecture eliminate this class of error?
Using twisted.protocol.basic can 2 lineReceived events happen
simultaneously? How is this addressed?
Theodore E. Patrick
PowerSDK - Code for a distributed world
I've built an SNMP Protocol for Twisted (based on a pattern from Patrick
K. O'Brien), but as I'm a rather new Twisted developer, I'm wondering if
someone more "in the know" could take a look at the package and see if I
got the "ideas" right. That is, whether I'm going about the entire
thing incorrectly/correctly, or whether I've missed anything that would
be obvious to an experienced twisted developer.
The protocol provides for sending get, getnext and getbulk requests, but
doesn't yet support trap or answering any query (i.e. in SNMP-eese it's
a manager-only protocol at the moment, not an agent-side protocol).
I'm particularly interested in:
* whether the timeouts are handled properly (we do a crude callLater
and check for deferred.called for them), is there a more elegant
Twisted mechanism for handling timed-out operations?
* whether the message IDs are handled properly (we just store all
"live" messages in a dictionary and delete them when they are
timed out or responded to), is there some more elegant Twisted
* whether the entire approach is okay. I put most of the code and
API on the protocol object, with a helper object for managing
tabular downloads. Is there a more "Twisted" way of doing this?
Should the get method on the protocol be implemented as a separate
object driving the protocol as well? What should be in the
"protocol" level, (as opposed to higher-level "application" code)?
Package is here:
It requires pysnmp-3.3.5, available here:
You'll need an SNMP agent against which to test (as well as some OIDs
for that agent), as the ips in the scripts won't work without the proper
community IDs (or from unrecognised manager IPs, for that matter).
Mike C. Fletcher
Designer, VR Plumber, Coder
I'm writing a socks proxy that uses ssh tunnels for connections, I can
get it working by making my connectClass listenTCP with a
forwarding.SSHListenForwardingFactory and then ClientCreator a
SOCKSv4Outgoing to connectTCP, but obviously that's a bad method.
How can I cut the listen/connect? Is there a way I can do it at that
level or do I need to implement my own .connectSSH method?
It seems I need to get both sides placed in the reactor somehow,
but SSHChannel.conn doesn't have a fileno() so addReader doesn't accept it.
(Is addReader the right function? I found it in the curses example and
am assuming it's just a generic file descriptor handler)