twisted.web.template is great to have. I'm doing a client's web app
project with (so far) just twisted. So far the only thing I really
miss from nevow is that I cannot load a template from a fragment
identifier in an xml document, but just for reasons of convenience.
I need to know who is logged in. Twisted offers
twisted.web.guard.HTTPAuthSessionWrapper to perform the initial
authentication, but then when a page element wants to know the
identity of the authenticated user, there seems to be no provision for
this. Furthermore, there seems to be no place in the classes I am
invited to write to work with twisted.web.guard where both the request
object and the avatarId exist at the same time.
The only opportunity I have to bind a user identity/object to a
request is by constructing and throwing away a new Resource tree for
each request in requestAvatar. I decided that was probably not what I
was meant to do. Instead, I have done something that turns out to
smell very bad to solve this problem. What was the correct solution?
Mine was to subclass HTTPAuthSessionWrapper and override
_authorizedResource and _login in order to pass the request object as
the mind. From there I can use request.setComponent in requestAvatar
and request.removeComponent in the logout callback (just for fun) to
associate an authenticated user object with the request. I'm not even
sure that's what "mind" is for, and it's not cool copying and pasting
the body of a couple of methods out of the library.
My next task appears to be to write a credential factory that can take
credentials out of the cookies or session, to support a friendly login
interface. Again I feel as though I am whacking my way through what
should be a clear trail. It's dangerous stuff to be writing as
application code. Am I just expecting too much from twisted.web a la
carte? Is nevow a viable choice anymore?
TIA for just one or two lines of wisdom.
Which is the state about twisted-web2 ? will be merged at end at web namespace ?
And another question about twisted-web2.proxy module, there are a
raise ImportError at first line in last version, really doesnt work ?
somebody know something about this ?
for example, I want to run two tasks ( using thread ), waiting while this tasks is end and after run next several tasks
How to do this using twisted ? Any example ?
1) 1,2 tasks begin ( thread )
2) waiting while all tasks is ends
4) run 3,4,5,6,7 tasks ( thread )
5) waiting while all tasks is ends
I wonder if someone could help me with making of a streaming proxy - I
understand how producers/consumers work with general twisted, but
unsure of the best strategy in case of twisted.web.
So, the problem is as follows: frontend that accepts a request with
some headers I must process and a potentially large body. The latter
I'd like to be able to proxy in a streaming manner to another http
server. Any suggestions?
--text follows this line--
I'm trying to write a hybrid server that serves either HTTP or my own
custom protocol depending on how it's addressed (distantly inspired by
the IRC bouncer ZNC). If it receives a standard GET, POST, HEAD,
etc. it sends HTTP traffic, or if it receives the bareword `CORDELIA',
it switches to Cordelia mode.
HTTP works fine with Twisted.Web. I can serve pages over HTTP (which is
my desired outcome). However, I'm not sure how to write the Cordelia
handling code. I've tried my own custom `render_CORDELIA' function, but
it acts too much like HTTP (ie. it returns a result and terminates the
connection), which is not what I want, as the protocol I've designed
involves establishing a two-way conversation, not a single request and
So I'm pretty much stuck in a rut. I don't want to totally reinvent the
wheel just to be able to protocol-switch; I'd prefer to make use of
existing code from Twisted. How do I hijack Twisted.Web to add protocol
<lvh> PAS MAINTENANT CHEF! CHUIS EN TRAIN DE BRANCHER LE REACTEURRRRR
On behalf of Twisted Matrix Laboratories, I am honored to announce the
release of Twisted 11.0.0.
* a new templating system in Twisted Web, "twisted.web.template",
derived from Divmod Nevow.
* improved behavior of subprocess spawning on FreeBSD.
* the 'twistd mail' plugin now uses the endpoints API, providing a
more consistent command line and compatibility with endpoint plugins.
* twisted.plugin no longer emits a confusing traceback when it can't
write a cache file.
and numerous other bugfixes and documentation improvements. For more
information, see the NEWS file.
Download it now from:
or install the 'Twisted' package from PyPI.
Many thanks to Glyph Lefkowitz and Jean-Paul Calderone for
sanity-checking the pre-releases and release, and to the enthusiastic
PyCon 2011 sprinters who annihilated dozens of tickets. Thanks to
*everyone* who contributed tickets, patches, documentation, reviews,
buildbots, feedback, and assistance to fellow users and developers
leading up to this release. It is truly a group effort.
is a testament to how much work was done in March alone.