From 360f778ade86a664cd324babf2cf3b0dc1ab300a Mon Sep 17 00:00:00 2001 From: mdipierro Date: Tue, 14 Aug 2012 20:26:43 -0500 Subject: [PATCH] fixed admin url upload, thanks Marin --- VERSION | 2 +- applications/admin/controllers/default.py | 53 ++++++++++++----------- 2 files changed, 28 insertions(+), 27 deletions(-) diff --git a/VERSION b/VERSION index 1ebda134..f10e0eb4 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -Version 2.00.0 (2012-08-14 19:32:03) dev +Version 2.00.0 (2012-08-14 20:26:37) dev diff --git a/applications/admin/controllers/default.py b/applications/admin/controllers/default.py index d4fbf0e8..556188eb 100644 --- a/applications/admin/controllers/default.py +++ b/applications/admin/controllers/default.py @@ -233,38 +233,39 @@ def site(): elif form_update.vars.url: # fetch an application via URL or file upload - if form_update.vars.url: - try: - form_update.vars.file = \ - urllib.urlopen(form_update.vars.url) - except Exception, e: - session.flash = \ - DIV(T('Unable to download app because:'),PRE(str(e))) - redirect(URL(r=request)) - fname = form_update.vars.url + try: + f = urllib.urlopen(form_update.vars.url) + if f.code == 404: + raise Exception("404 file not found") + except Exception, e: + session.flash = \ + DIV(T('Unable to download app because:'),PRE(str(e))) + redirect(URL(r=request)) + fname = form_update.vars.url elif form_update.accepted and form_update.vars.file: fname = request.vars.file.filename + f = request.vars.file.file + + if f: appname = cleanpath(form_update.vars.name) - installed = app_install(appname, request.vars.file.file, + installed = app_install(appname, f, request, fname, overwrite=form_update.vars.overwrite) - if installed: - msg = 'application %(appname)s installed with md5sum: %(digest)s' - if MULTI_USER_MODE: - db.app.insert(name=appname,owner=auth.user.id) - log_progress(appname) - session.flash = T(msg, dict(appname=appname, - digest=md5_hash(installed))) - elif form_update.vars.overwrite: - msg = 'unable to install application "%(appname)s"' - session.flash = T(msg, dict(appname=form_update.vars.name)) - - else: - msg = 'unable to install application "%(appname)s"' - session.flash = T(msg, dict(appname=form_update.vars.name)) - - redirect(URL(r=request)) + if f and installed: + msg = 'application %(appname)s installed with md5sum: %(digest)s' + if MULTI_USER_MODE: + db.app.insert(name=appname,owner=auth.user.id) + log_progress(appname) + session.flash = T(msg, dict(appname=appname, + digest=md5_hash(installed))) + elif f and form_update.vars.overwrite: + msg = 'unable to install application "%(appname)s"' + session.flash = T(msg, dict(appname=form_update.vars.name)) + else: + msg = 'unable to install application "%(appname)s"' + session.flash = T(msg, dict(appname=form_update.vars.name)) + redirect(URL(r=request)) regex = re.compile('^\w+$')