Could you give me some guidance on how to set up a cherry py server? My host has a cherry py app but I don't know anything about it.
On Feb 8, 5:00 am, Branko Vukelić <[email protected]> wrote: > Oetzi, > > Mod wsgi is really weird. Last mod_wsgi deployment for me was the > final one, and I never used mod_wsgi again after that. I had weird > issues with it as well, and the documentation wasn't particularly > clear about the issues. Anyway, I suggest you run with fastcgi or even > better, using a dedicated WSGI server like cherrypy or bjoern with a > static file server like lighttpd or nginx as a frontend which reverse > proxies to your WSGI server. That type of setup is usually much ligher > and performs very well. > > > > > > > > > > On Tue, Feb 8, 2011 at 2:46 AM, Oetzi <[email protected]> wrote: > > Hey all, > > > I was wondering if someone would be able to help me with a problem > > that is driving me mad. > > Here is my script: > > > #!/usr/local/bin/python2.6 > > import cgitb; cgitb.enable() > > import sys > > import web, os, random, time, sqlite3 > > > def cgidebugerror(): > > > _wrappedstdout = sys.stdout > > > sys.stdout = web._oldstdout > > cgitb.handler() > > > sys.stdout = _wrappedstdout > > > web.internalerror = cgidebugerror > > > urls = ('/', 'upload', > > '/progress+', 'progress', > > '/file+', 'fileServe', > > '/admin', 'admin') > > > #db = web.database(dbn='sqlite', db='filedb') > > render = web.template.render('/home/oetzi/webapps/mod/htdocs/ > > templates/') > > > sessions = {} > > prog = 0 > > up = 0 > > > class session: > > > def __init__(self): > > > self.progress = 0 > > self.title = "" > > self.finished = False > > > def advance(self): > > > self.progress = self.progress + 1 > > > class fileServe: > > > def GET(self): > > > arg = web.input(arg=None) > > keys = {} > > keys['key'] = arg.key > > path = db.select('files', keys, what='path', > > where='key=$key') > > > #if not path: > > > # return "This file doesn't seem to exist..." > > > try: > > > download = open(path[0].path, 'r') > > > except IndexError: > > > return "This file doesn't seem to exist..." > > > web.header('Content-type', 'application/file') > > return download.read() > > > class upload: > > > paths = {} > > > def GET(self): > > > global sessions > > > #render html file > > code = 0 > > > while sessions.has_key(str(code)): > > > code = random.randint(0, 10000000000000) > > > newSesh = session() > > sessions[str(code)] = newSesh > > > return render.index(code) > > > def POST(self): > > > global sessions > > global up > > > #upload file from form > > submit = web.input(myfile={}) > > > code = submit.code > > fileU = submit.myfile > > > up = sessions[code] > > > filepath = fileU.filename.replace('\\','/') > > name = filepath.split('/')[-1] > > path = '/home/oetzi/webapps/mod/htdocs/files/' + name > > upload.paths[code] = "/file?key=" + name > > > out = open(path, 'wb', 1000) > > > while (True): > > > packet = fileU.file.read(1000) > > sessions[code].advance() > > > if not packet: > > > break > > > else: > > > out.write(packet) > > > out.close() > > > #block until client has been updated > > while not sessions[code].finished: > > > sessions[code].progress = -1 > > > #commit to db > > title = sessions[code].title > > #db.insert('files', title=title, key=name, path=path) > > > #clean up > > sessions.pop(code) > > path = "http://oetzi.webfactional.com" + > > upload.paths.pop(code) > > > return title + ": " + path > > > class progress: > > > def GET(self): > > > global sessions > > global prog > > > #take in current title and status for user with code and > > return > > progress > > arg = web.input(arg=None) > > code = arg.code > > prog = sessions[code] > > > if int(arg.status) > 0: > > > sessions[code].title = arg.title > > path = str(upload.paths[code]) > > sessions[code].finished = True > > return path > > > return sessions[code].progress > > > def POST(self): > > > pass > > > class admin: > > > def GET(self): > > > global prog > > global up > > > return prog == up > > > app = web.application(urls, globals(), autoreload=False) > > application = app.wsgifunc() > > > I basically upload a file using a post request from a form and then > > update the progress based on the amount of bytes upload. For some > > reason when I run this on my mod_wsgi server the progress fails to > > increase on an upload. It seems as if the GET request I use to get the > > progress and the POST request that increments the progress are using > > different objects. Does anybody have any idea what is happening? > > > -- > > You received this message because you are subscribed to the Google Groups > > "web.py" group. > > To post to this group, send email to [email protected]. > > To unsubscribe from this group, send email to > > [email protected]. > > For more options, visit this group > > athttp://groups.google.com/group/webpy?hl=en. > > -- > Branko Vukelic > > [email protected]http://www.brankovukelic.com/ -- You received this message because you are subscribed to the Google Groups "web.py" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/webpy?hl=en.
