[Twisted-Python] 5 small patches

Bill Gribble grib at billgribble.com
Mon Jun 9 16:01:05 EDT 2003


Here are some small patches I have made while working with Twisted
recently.  They are all harmless with the possible exception of #4.

(1) gtk2 manhole problem.  I got backtraces upon connecting to a
    manholed app.  This fixes them. 

Index: twisted/manhole/ui/gtk2manhole.py
===================================================================
RCS file: /cvs/Twisted/twisted/manhole/ui/gtk2manhole.py,v
retrieving revision 1.7
diff -r1.7 gtk2manhole.py
245c245
<             if isinstance(content, StringTypes):
---
>             if isinstance(content, types.StringTypes):


(2) Found this while grepping for the source of the gtk2 manhole
    problem.  It's the same problem. 

Index: twisted/internet/app.py
===================================================================
RCS file: /cvs/Twisted/twisted/internet/app.py,v
retrieving revision 1.96
diff -r1.96 app.py
415c415
<             if isinstance(port, StringTypes):
---
>             if isinstance(port, types.StringTypes):

(3) Fix Woven's string escaping for generation of JavaScript to be
    evaluated in LivePages.  This is pretty important; things like 
    <textarea> and <pre> content were mangled by the old code. 

Index: twisted/web/woven/controller.py
===================================================================
RCS file: /cvs/Twisted/twisted/web/woven/controller.py,v
retrieving revision 1.60
diff -r1.60 controller.py
368,369d367
<             nodeXML = nodeXML.replace('\n', '')
<             nodeXML = nodeXML.replace('\r', '')
371a370,378
>             nodeXML = nodeXML.replace('"', '\\"')
>             nodeXML = nodeXML.replace('\n', '\\n')
>             nodeXML = nodeXML.replace('\r', ' ')
>             nodeXML = nodeXML.replace('\b', ' ')
>             nodeXML = nodeXML.replace('\t', ' ')
>             nodeXML = nodeXML.replace('\000', ' ')
>             nodeXML = nodeXML.replace('\v', ' ')
>             nodeXML = nodeXML.replace('\f', ' ')
>

(4) Patch to Woven's Guard for setting up sessions in LivePages.  I'm
    not 100% sure about this one, but it works for me.  I have attached
a 
    simple demonstration that fails under CVS but (I believe) should
work. 

Index: twisted/web/woven/guard.py
===================================================================
RCS file: /cvs/Twisted/twisted/web/woven/guard.py,v
retrieving revision 1.17
diff -r1.17 guard.py
209,210c209,211
<             request.getSession = lambda interface=None: None
<             return self.resource.getChildWithDefault(path, request)
---
>             #request.getSession = lambda interface=None: None
>             #return self.resource.getChildWithDefault(path, request)
>             return Redirect(request.pathRef().fullURL(request) +
INIT_SESSION)

(5) Add a "template=" keyword arg to LivePage constructor.  This is
patterned
    after the existing code in Page. 

Index: twisted/web/woven/page.py
===================================================================
RCS file: /cvs/Twisted/twisted/web/woven/page.py,v
retrieving revision 1.21
diff -r1.21 page.py
76,78c76,80
<     def __init__(self, m=None, templateFile=None, inputhandlers=None,
templateDirectory=None,
<                  controllers=None, *args, **kwargs):
<         model.Model.__init__(self, *args, **kwargs)
---
>     def __init__(self, m=None, templateFile=None, inputhandlers=None,
>                  templateDirectory=None, controllers=None, *args,
**kwargs):
>         template = kwargs.setdefault('template', None)
>         del kwargs['template']
>
82a85
>
88c91,93
<                            templateFile=templateFile,
templateDirectory=templateDirectory)
---
>                            templateFile=templateFile,
>                            templateDirectory=templateDirectory,
>                            template=template)
90a96
>



-------------- next part --------------
A non-text attachment was scrubbed...
Name: patch-4-demo.tgz
Type: application/x-compressed-tar
Size: 436 bytes
Desc: not available
Url : http://twistedmatrix.com/pipermail/twisted-python/attachments/20030609/fb0e832e/attachment.bin 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : http://twistedmatrix.com/pipermail/twisted-python/attachments/20030609/fb0e832e/attachment.pgp 


More information about the Twisted-Python mailing list