return functions

G

gert

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
 
G

gert

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
 
G

gert

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

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 ?
 
G

gert

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 ?

Wait a minute why am i not using this ?

http://docs.python.org/3.0/library/wsgiref.html#wsgiref.util.request_uri

And just make my own server ?
 
G

Graham Dumpleton

Aldo i like the cerrypywsgiserver 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 orwsgi

You seem to have finally discovered that when using Apache/mod_wsgi,
Apache does a level of URL matching to filesystem based resources.
This isn't automatic in normal WSGI servers unless you use a WSGI
middleware that does the mapping for you. :)

Graham
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,291
Messages
2,571,493
Members
48,158
Latest member
MariQuinon

Latest Threads

Top