return functions

gert gert.cuykens at gmail.com
Sat May 2 18:17:54 EDT 2009


On May 2, 10:58 pm, gert <gert.cuyk... at gmail.com> wrote:
> On May 2, 10:44 pm, gert <gert.cuyk... at gmail.com> wrote:
>
> > Aldo i like the cerrypy wsgi server very much, i do not like the tools
> > that go with it
> > so i am stuck with a configuration file that looks like this
>
> >http://pastebin.com/m4d8184bc
>
> > After 152 line I finally arrived to a point where i was thinkig "thats
> > it, this is like going to work on a uni cycle and is just plain
> > ridicules"
>
> > So how can i generate some functions something like
>
> > def generate(url,type): # where type could be htm js css or wsgi
>
> I was thinking something like this ?
>
> def static(url, mime):
>     def application(environ, response):
>         f=open(os.path.join(os.path.dirname(__file__), url),'rb')
>         l=os.fstat(f.fileno()).st_size
>         response('200 OK', [('Content-type', mime+';charset=utf-8'),
> ('Content-Length', str(l))])
>         return FileWrapper(f, 8192)
>     return application

it works, i reduced it to this :-)

http://code.google.com/p/appwsgi/source/browse/trunk/server.py

any other suggestions to make it smaller and more automatic ?




More information about the Python-list mailing list