You are not logged in Log in Join
You are here: Home » Members » adytumsolutions » PyCon2004 » IRCTwistedZopeNotes » wikipage_view

Log in
Name

Password

 
 
Zope2 Sprint » TwistedZope »

IRCTwistedZopeNotes

-> mcdonc I had to add some extra config stuff to get it to work with mine, but it's up and running now... what are some best guesses as to the next steps?

mcdonc well, i was messing around with making the twisted headers reflect the zope content length and whatnot...

mcdonc and i think what needs to be done is to either find a hack to do so in the current way we're doing it.

mcdonc or to write a wrapper class for a zope response which will do the right thing when headers are set.

mcdonc (where the right thing means calling "twistedrequest.setResponseHeader(foo, bar)" or somesuch.

mcdonc twisted doesn't expose response at all, all response methods are methods of its request.

mcdonc so that means the wrapper class needs to accept the twisted request and call back into it when things like setHeader are called on it.

-> mcdonc I can take a look at that, unless you are too curious to resist ;-)

mcdonc i tried hacking it and using the "asis" capability of twisted's file server (which should just return the data unmolested and without headers) but that didnt work.

mcdonc sure, go for it!

mcdonc i created a zope2sprint channel if you'd rather not talk in #zope due to noise and whatnot.

----

mcdonc> so duncan, what needs to happen is on the line that calls into publish_module, i think a response needs to be passed in which is an instance of that twisted wrapper class.

> the class that wraps twisted request/response and gives it in Zope's required format?

mcdonc> it wraps twisted's request only but yes... the class constructor should be passed the twisted request and the wrapper class' setHeader method should say something like +"self.twistedrequest.setResponseHeader(foo, bar) (probably not exactly, i didnt look at the API).

----

mcdonc> oubiwann: works good. cookies don't work and auth doesnt work, but i can browse around!

mcdonc> oubiwann: that really rocks... fwiw, it still appears to work if you get HTTPResponse? out of ZPublisher? instead of ZServer.

> I can't take any credit; I was just a helpful cheerleader ;-)

> I'm excited, though... there's all kinds of possibility... I need to really dig in now and get to know both Zope and twisted at this level first, though

mcdonc> right.. well, fwiw, i think the key to getting auth working is to pass in the base64-encoded username/password combo into Zope's CGI environment as HTTP_AUTHORIZATION. I'm not sure how +to get that out of twisted's request, but i'm sure it's possible.

mcdonc> oubiwann: try this... add this to the env dict

mcdonc> "HTTP_AUTHORIZATION": Basic %s % base64.encodestring(admin:123),

mcdonc> (make sure to import base64 and to change the username password to whatever you want.

mcdonc> now you can browse the mgmt interface. ;-)