[Twisted-Python] Twisted Resources / PathArgs
Clark C. Evans
cce at clarkevans.com
Wed Feb 26 05:20:21 EST 2003
| class PathArgs(Resource):
| """ Provides a mechanism to add 'pathargs' attribute to
| each request, and to populate it with instances of
| key:value pairs found in child paths.
| """
| def getChild(self,path,request):
| pair = path.split(':')
| if 2 == len(pair):
| request.pathargs[pair[0]] = pair[1]
| return self
| return Resource.getChild(self,path,request)
| def getChildWithDefault(self,path,request):
| if not(hasattr(request,'pathargs')):
| request.pathargs = {}
| return Resource.getChildWithDefault(self,path,request)
I was wondering if anyone would like to add the above code to the
web package so that people can use /path:args/servlet right out
of the box. I hearby put the above code snippet into the public domain.
Best,
Clark
More information about the Twisted-Python
mailing list