From ad8c1165b7cf5eaff692b40b29a96e9add38d47b Mon Sep 17 00:00:00 2001 From: mdipierro Date: Sun, 30 Jun 2013 11:29:43 -0500 Subject: [PATCH 1/8] removed BaseException = Exception logic, thanks Jonathan --- VERSION | 2 +- gluon/http.py | 10 +--------- gluon/tools.py | 25 ++++++++++--------------- gluon/widget.py | 9 ++------- 4 files changed, 14 insertions(+), 32 deletions(-) diff --git a/VERSION b/VERSION index ee2c404b..533b2fec 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -Version 2.6.0-development+timestamp.2013.06.30.10.46.28 +Version 2.6.0-development+timestamp.2013.06.30.11.28.52 diff --git a/gluon/http.py b/gluon/http.py index fd429f9d..dda977b5 100644 --- a/gluon/http.py +++ b/gluon/http.py @@ -51,18 +51,10 @@ defined_status = { 505: 'HTTP VERSION NOT SUPPORTED', } -# If web2py is executed with python2.4 we need -# to use Exception instead of BaseException - -try: - BaseException -except NameError: - BaseException = Exception - regex_status = re.compile('^\d{3} \w+$') -class HTTP(BaseException): +class HTTP(Exception): def __init__( self, diff --git a/gluon/tools.py b/gluon/tools.py index e2e2bd09..592de93c 100644 --- a/gluon/tools.py +++ b/gluon/tools.py @@ -4437,7 +4437,9 @@ class Service(object): jsonrpc_2 = data.get('jsonrpc') if jsonrpc_2: #hand over to version 2 of the protocol return self.serve_jsonrpc2(data) - id, method, params = data['id'], data['method'], data.get('params', '') + id, method, params = data.get('id'), data.get('method'), data.get('params', []) + if id is None: + return return_error(0, 100, 'missing id') if not method in methods: return return_error(id, 100, 'method "%s" does not exist' % method) try: @@ -4450,15 +4452,12 @@ class Service(object): return return_response(id, s) except Service.JsonRpcException, e: return return_error(id, e.code, e.info) - except BaseException: - etype, eval, etb = sys.exc_info() - code = 100 - message = '%s: %s' % (etype.__name__, eval) - data = request.is_local and traceback.format_tb(etb) - return return_error(id, code, message, data) except: etype, eval, etb = sys.exc_info() - return return_error(id, 100, 'Exception %s: %s' % (etype, eval)) + message = '%s: %s' % (etype.__name__, eval) + data = request.is_local and traceback.format_tb(etb) + logger.warning('jsonrpc exception %s\n%s' % (message, traceback.format_tb(etb))) + return return_error(id, 100, message, data) def serve_jsonrpc2(self, data=None, batch_element=False): @@ -4560,14 +4559,11 @@ class Service(object): raise e except Service.JsonRpcException, e: return return_error(id, e.code, e.info) - except BaseException: - etype, eval, etb = sys.exc_info() - code = -32099 - data = '%s: %s\n' % (etype.__name__, eval) + str(request.is_local and traceback.format_tb(etb)) - return return_error(id, code, data=data) except: etype, eval, etb = sys.exc_info() - return return_error(id, -32099, data='Exception %s: %s' % (etype, eval)) + data = '%s: %s\n' % (etype.__name__, eval) + str(request.is_local and traceback.format_tb(etb)) + logger.warning('%s: %s\n%s') % (etype.__name__, eval, traceback.format_tb(etb)) + return return_error(id, -32099, data=data) def serve_xmlrpc(self): @@ -5214,7 +5210,6 @@ class Wiki(object): def automenu(self): """adds the menu if not present""" - request = current.request if not self.wiki_menu_items and self.settings.controller and self.settings.function: self.wiki_menu_items = self.menu(self.settings.controller, self.settings.function) diff --git a/gluon/widget.py b/gluon/widget.py index cbd0a3f7..7049af95 100644 --- a/gluon/widget.py +++ b/gluon/widget.py @@ -39,11 +39,6 @@ except: have_winservice = False -try: - BaseException -except NameError: - BaseException = Exception - ProgramName = 'web2py Web Framework' ProgramAuthor = 'Created by Massimo Di Pierro, Copyright 2007-' + str( datetime.datetime.now().year) @@ -53,8 +48,8 @@ ProgramInfo = '''%s %s %s''' % (ProgramName, ProgramAuthor, ProgramVersion) -if not sys.version[:3] in ['2.4', '2.5', '2.6', '2.7']: - msg = 'Warning: web2py requires Python 2.4, 2.5 (recommended), 2.6 or 2.7 but you are running:\n%s' +if not sys.version[:3] in ['2.5', '2.6', '2.7']: + msg = 'Warning: web2py requires Python 2.5, 2.6 or 2.7 but you are running:\n%s' msg = msg % sys.version sys.stderr.write(msg) From 1e8c9e89f32567a85bf7cb9e3bb9ef0e4e3fdec3 Mon Sep 17 00:00:00 2001 From: mdipierro Date: Mon, 1 Jul 2013 05:51:57 -0500 Subject: [PATCH 2/8] possibly fixed issue 1570:Recent web2py does no longer support table-aliasing, thanks Dominic --- VERSION | 2 +- gluon/dal.py | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/VERSION b/VERSION index 533b2fec..27121973 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -Version 2.6.0-development+timestamp.2013.06.30.11.28.52 +Version 2.6.0-development+timestamp.2013.07.01.05.51.11 diff --git a/gluon/dal.py b/gluon/dal.py index a678c820..6c184b18 100644 --- a/gluon/dal.py +++ b/gluon/dal.py @@ -8485,10 +8485,10 @@ class Table(object): def __str__(self): if self._ot is not None: - return self._db._adapter.QUOTE_TEMPLATE % self._ot - #if 'Oracle' in str(type(self._db._adapter)): # <<< patch - # return '%s %s' % (self._ot, self._tablename) # <<< patch - #return '%s AS %s' % (self._ot, self._tablename) + ot = self._db._adapter.QUOTE_TEMPLATE % self._ot + if 'Oracle' in str(type(self._db._adapter)): + return '%s %s' % (ot, self._tablename) + return '%s AS %s' % (ot, self._tablename) return self._tablename def _drop(self, mode = ''): From afa96da8e908c4bc53af3e8b478935e3216ac850 Mon Sep 17 00:00:00 2001 From: Aurelio Tinio Date: Mon, 1 Jul 2013 10:43:33 -0700 Subject: [PATCH 3/8] check for __memcache_client not __mc_instance --- gluon/contrib/memcache/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gluon/contrib/memcache/__init__.py b/gluon/contrib/memcache/__init__.py index 9f85ec57..a2a095dd 100644 --- a/gluon/contrib/memcache/__init__.py +++ b/gluon/contrib/memcache/__init__.py @@ -15,7 +15,7 @@ from gluon import current DEFAULT_TIME_EXPIRE = 300 # seconds (must be the same as cache.ram) def MemcacheClient(*a, **b): - if not hasattr(current,'__mc_instance'): + if not hasattr(current,'__memcache_client'): current.__memcache_client = MemcacheClientObj(*a, **b) return current.__memcache_client From a449c4ede58bef15c6d81115e03ead5df06fa2d8 Mon Sep 17 00:00:00 2001 From: mdipierro Date: Tue, 2 Jul 2013 07:17:37 -0500 Subject: [PATCH 4/8] fixed issue 1570:Recent web2py does no longer support table-aliasing, thanks Dominic --- VERSION | 2 +- gluon/dal.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/VERSION b/VERSION index 27121973..942e1cb1 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -Version 2.6.0-development+timestamp.2013.07.01.05.51.11 +Version 2.6.0-development+timestamp.2013.07.02.07.16.53 diff --git a/gluon/dal.py b/gluon/dal.py index 6c184b18..b8396be0 100644 --- a/gluon/dal.py +++ b/gluon/dal.py @@ -1364,7 +1364,7 @@ class BaseAdapter(ConnectionPool): def expand(self, expression, field_type=None): if isinstance(expression, Field): - out = '%s.%s' % (expression.table, expression.name) + out = '%s.%s' % (expression.table._tablename, expression.name) if field_type == 'string' and not expression.type in ( 'string','text','json','password'): out = 'CAST(%s AS %s)' % (out, self.types['text']) From 182bbbdcc2eb3c0e65e272a3c41fbf9bdb2b0664 Mon Sep 17 00:00:00 2001 From: mdipierro Date: Tue, 2 Jul 2013 07:21:09 -0500 Subject: [PATCH 5/8] fixed issue 1562:The dspval of integer value zero is nbsp not 0, thanks iiijjjiii --- VERSION | 2 +- gluon/sqlhtml.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/VERSION b/VERSION index 942e1cb1..83e7040f 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -Version 2.6.0-development+timestamp.2013.07.02.07.16.53 +Version 2.6.0-development+timestamp.2013.07.02.07.20.31 diff --git a/gluon/sqlhtml.py b/gluon/sqlhtml.py index 26720803..5db36e7c 100644 --- a/gluon/sqlhtml.py +++ b/gluon/sqlhtml.py @@ -1116,7 +1116,7 @@ class SQLFORM(FORM): inp = self.widgets[field_type].widget(field, default) xfields.append((row_id, label, inp, comment)) - self.custom.dspval[fieldname] = dspval or nbsp + self.custom.dspval[fieldname] = dspval if (dspval is not None) else nbsp self.custom.inpval[ fieldname] = inpval if not inpval is None else '' self.custom.widget[fieldname] = inp From 9ebab678c600545801f43b8bd56cbb5563595b6a Mon Sep 17 00:00:00 2001 From: mdipierro Date: Tue, 2 Jul 2013 07:40:00 -0500 Subject: [PATCH 6/8] fixed problem with admin replacing text, thanks Niphlod --- VERSION | 2 +- applications/admin/controllers/default.py | 26 --------------------- applications/admin/static/js/ajax_editor.js | 4 ++-- gluon/admin.py | 2 +- 4 files changed, 4 insertions(+), 30 deletions(-) diff --git a/VERSION b/VERSION index 83e7040f..983040df 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -Version 2.6.0-development+timestamp.2013.07.02.07.20.31 +Version 2.6.0-development+timestamp.2013.07.02.07.39.15 diff --git a/applications/admin/controllers/default.py b/applications/admin/controllers/default.py index 5e0e3ce5..a23ea5c2 100644 --- a/applications/admin/controllers/default.py +++ b/applications/admin/controllers/default.py @@ -458,32 +458,6 @@ def remove_compiled_app(): redirect(URL('site')) -def delete(): - """ Object delete handler """ - app = get_app() - filename = '/'.join(request.args) - sender = request.vars.sender - - if isinstance(sender, list): # ## fix a problem with Vista - sender = sender[0] - - if 'nodelete' in request.vars: - redirect(URL(sender, anchor=request.vars.id)) - elif 'delete' in request.vars: - try: - full_path = apath(filename, r=request) - lineno = count_lines(open(full_path, 'r').read()) - os.unlink(full_path) - log_progress(app, 'DELETE', filename, progress=-lineno) - session.flash = T('file "%(filename)s" deleted', - dict(filename=filename)) - except Exception: - session.flash = T('unable to delete file "%(filename)s"', - dict(filename=filename)) - redirect(URL(sender, anchor=request.vars.id2)) - return dict(filename=filename, sender=sender) - - def delete(): """ Object delete handler """ app = get_app() diff --git a/applications/admin/static/js/ajax_editor.js b/applications/admin/static/js/ajax_editor.js index 4a0560c4..9f3fca87 100644 --- a/applications/admin/static/js/ajax_editor.js +++ b/applications/admin/static/js/ajax_editor.js @@ -232,8 +232,8 @@ function load_file (url) { if (typeof(json['plain_html']) !== undefined) { if (jQuery('#' + json['id']).length === 0 || json['force'] === true) { // Create a tab and put the code in it - var tab_header = '
  • filenameDefault
  • '.replace(/idDefault/, json['id']).replace(/filenameDefault/, json['filename'] ); - var tab_body = '
    htmlDefault
    '.replace(/htmlDefault/, json['plain_html']).replace(/idDefault/, json['id']); + var tab_header = '
  • '+json['filename']+'
  • '; + var tab_body = '
    ' + json['plain_html'] + '
    '; if (json['force'] === false) { jQuery('#filesTab').append(jQuery(tab_header)); jQuery('#myTabContent').append(jQuery(tab_body)); diff --git a/gluon/admin.py b/gluon/admin.py index 8801d44b..abaaf319 100644 --- a/gluon/admin.py +++ b/gluon/admin.py @@ -377,7 +377,7 @@ def check_new_version(myversion, version_URL): version = urlopen(version_URL).read() pversion = parse_version(version) pmyversion = parse_version(myversion) - except Exception,e: + except IOError: import traceback print traceback.format_exc() return -1, myversion From 6017e749ebc97527011aafec9abd4d3b674b0e69 Mon Sep 17 00:00:00 2001 From: mdipierro Date: Tue, 2 Jul 2013 08:03:51 -0500 Subject: [PATCH 7/8] no more collapsible menu if not is_mobile, thanks Paolo --- VERSION | 2 +- applications/welcome/views/layout.html | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/VERSION b/VERSION index 983040df..53a00cea 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -Version 2.6.0-development+timestamp.2013.07.02.07.39.15 +Version 2.6.0-development+timestamp.2013.07.02.08.03.03 diff --git a/applications/welcome/views/layout.html b/applications/welcome/views/layout.html index 3a99857b..edf4e11e 100644 --- a/applications/welcome/views/layout.html +++ b/applications/welcome/views/layout.html @@ -71,16 +71,16 @@
    {{=response.flash or ''}}