diff --git a/VERSION b/VERSION index bee3b373..3ab99c29 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -Version 2.8.2-stable+timestamp.2013.12.17.16.49.17 +Version 2.8.2-stable+timestamp.2014.01.07.02.13.10 diff --git a/applications/admin/controllers/appadmin.py b/applications/admin/controllers/appadmin.py index 44efa2d5..a74f0569 100644 --- a/applications/admin/controllers/appadmin.py +++ b/applications/admin/controllers/appadmin.py @@ -16,6 +16,8 @@ try: except ImportError: pgv = None +is_gae = request.env.web2py_runtime_gae or False + # ## critical --- make a copy of the environment global_env = copy.copy(globals()) @@ -359,36 +361,43 @@ def state(): def ccache(): - cache.ram.initialize() - cache.disk.initialize() + if is_gae: + form = FORM( + P(TAG.BUTTON(T("Clear CACHE?"), _type="submit", _name="yes", _value="yes"))) + else: + cache.ram.initialize() + cache.disk.initialize() - form = FORM( - P(TAG.BUTTON( - T("Clear CACHE?"), _type="submit", _name="yes", _value="yes")), - P(TAG.BUTTON( - T("Clear RAM"), _type="submit", _name="ram", _value="ram")), - P(TAG.BUTTON( - T("Clear DISK"), _type="submit", _name="disk", _value="disk")), - ) + form = FORM( + P(TAG.BUTTON( + T("Clear CACHE?"), _type="submit", _name="yes", _value="yes")), + P(TAG.BUTTON( + T("Clear RAM"), _type="submit", _name="ram", _value="ram")), + P(TAG.BUTTON( + T("Clear DISK"), _type="submit", _name="disk", _value="disk")), + ) if form.accepts(request.vars, session): - clear_ram = False - clear_disk = False session.flash = "" - if request.vars.yes: - clear_ram = clear_disk = True - if request.vars.ram: - clear_ram = True - if request.vars.disk: - clear_disk = True - - if clear_ram: - cache.ram.clear() - session.flash += T("Ram Cleared") - if clear_disk: - cache.disk.clear() - session.flash += T("Disk Cleared") - + if is_gae: + if request.vars.yes: + cache.ram.clear() + session.flash += T("Cache Cleared") + else: + clear_ram = False + clear_disk = False + if request.vars.yes: + clear_ram = clear_disk = True + if request.vars.ram: + clear_ram = True + if request.vars.disk: + clear_disk = True + if clear_ram: + cache.ram.clear() + session.flash += T("Ram Cleared") + if clear_disk: + cache.disk.clear() + session.flash += T("Disk Cleared") redirect(URL(r=request)) try: @@ -414,6 +423,7 @@ def ccache(): 'oldest': time.time(), 'keys': [] } + disk = copy.copy(ram) total = copy.copy(ram) disk['keys'] = [] @@ -428,72 +438,81 @@ def ccache(): return (hours, minutes, seconds) - for key, value in cache.ram.storage.iteritems(): - if isinstance(value, dict): - ram['hits'] = value['hit_total'] - value['misses'] - ram['misses'] = value['misses'] - try: - ram['ratio'] = ram['hits'] * 100 / value['hit_total'] - except (KeyError, ZeroDivisionError): - ram['ratio'] = 0 - else: - if hp: - ram['bytes'] += hp.iso(value[1]).size - ram['objects'] += hp.iso(value[1]).count - ram['entries'] += 1 - if value[0] < ram['oldest']: - ram['oldest'] = value[0] - ram['keys'].append((key, GetInHMS(time.time() - value[0]))) - folder = os.path.join(request.folder,'cache') - if not os.path.exists(folder): - os.mkdir(folder) - locker = open(os.path.join(folder, 'cache.lock'), 'a') - portalocker.lock(locker, portalocker.LOCK_EX) - disk_storage = shelve.open( - os.path.join(folder, 'cache.shelve')) - try: - for key, value in disk_storage.items(): + if is_gae: + gae_stats = cache.ram.client.get_stats() + try: + gae_stats['ratio'] = ((gae_stats['hits'] * 100) / + (gae_stats['hits'] + gae_stats['misses'])) + except ZeroDivisionError: + gae_stats['ratio'] = T("?") + gae_stats['oldest'] = GetInHMS(time.time() - gae_stats['oldest_item_age']) + total.update(gae_stats) + else: + for key, value in cache.ram.storage.iteritems(): if isinstance(value, dict): - disk['hits'] = value['hit_total'] - value['misses'] - disk['misses'] = value['misses'] + ram['hits'] = value['hit_total'] - value['misses'] + ram['misses'] = value['misses'] try: - disk['ratio'] = disk['hits'] * 100 / value['hit_total'] + ram['ratio'] = ram['hits'] * 100 / value['hit_total'] except (KeyError, ZeroDivisionError): - disk['ratio'] = 0 + ram['ratio'] = 0 else: if hp: - disk['bytes'] += hp.iso(value[1]).size - disk['objects'] += hp.iso(value[1]).count - disk['entries'] += 1 - if value[0] < disk['oldest']: - disk['oldest'] = value[0] - disk['keys'].append((key, GetInHMS(time.time() - value[0]))) + ram['bytes'] += hp.iso(value[1]).size + ram['objects'] += hp.iso(value[1]).count + ram['entries'] += 1 + if value[0] < ram['oldest']: + ram['oldest'] = value[0] + ram['keys'].append((key, GetInHMS(time.time() - value[0]))) + folder = os.path.join(request.folder,'cache') + if not os.path.exists(folder): + os.mkdir(folder) + locker = open(os.path.join(folder, 'cache.lock'), 'a') + portalocker.lock(locker, portalocker.LOCK_EX) + disk_storage = shelve.open( + os.path.join(folder, 'cache.shelve')) + try: + for key, value in disk_storage.items(): + if isinstance(value, dict): + disk['hits'] = value['hit_total'] - value['misses'] + disk['misses'] = value['misses'] + try: + disk['ratio'] = disk['hits'] * 100 / value['hit_total'] + except (KeyError, ZeroDivisionError): + disk['ratio'] = 0 + else: + if hp: + disk['bytes'] += hp.iso(value[1]).size + disk['objects'] += hp.iso(value[1]).count + disk['entries'] += 1 + if value[0] < disk['oldest']: + disk['oldest'] = value[0] + disk['keys'].append((key, GetInHMS(time.time() - value[0]))) + finally: + portalocker.unlock(locker) + locker.close() + disk_storage.close() - finally: - portalocker.unlock(locker) - locker.close() - disk_storage.close() - - total['entries'] = ram['entries'] + disk['entries'] - total['bytes'] = ram['bytes'] + disk['bytes'] - total['objects'] = ram['objects'] + disk['objects'] - total['hits'] = ram['hits'] + disk['hits'] - total['misses'] = ram['misses'] + disk['misses'] - total['keys'] = ram['keys'] + disk['keys'] - try: - total['ratio'] = total['hits'] * 100 / (total['hits'] + + total['entries'] = ram['entries'] + disk['entries'] + total['bytes'] = ram['bytes'] + disk['bytes'] + total['objects'] = ram['objects'] + disk['objects'] + total['hits'] = ram['hits'] + disk['hits'] + total['misses'] = ram['misses'] + disk['misses'] + total['keys'] = ram['keys'] + disk['keys'] + try: + total['ratio'] = total['hits'] * 100 / (total['hits'] + total['misses']) - except (KeyError, ZeroDivisionError): - total['ratio'] = 0 + except (KeyError, ZeroDivisionError): + total['ratio'] = 0 - if disk['oldest'] < ram['oldest']: - total['oldest'] = disk['oldest'] - else: - total['oldest'] = ram['oldest'] + if disk['oldest'] < ram['oldest']: + total['oldest'] = disk['oldest'] + else: + total['oldest'] = ram['oldest'] - ram['oldest'] = GetInHMS(time.time() - ram['oldest']) - disk['oldest'] = GetInHMS(time.time() - disk['oldest']) - total['oldest'] = GetInHMS(time.time() - total['oldest']) + ram['oldest'] = GetInHMS(time.time() - ram['oldest']) + disk['oldest'] = GetInHMS(time.time() - disk['oldest']) + total['oldest'] = GetInHMS(time.time() - total['oldest']) def key_table(keys): return TABLE( @@ -502,9 +521,10 @@ def ccache(): **dict(_class='cache-keys', _style="border-collapse: separate; border-spacing: .5em;")) - ram['keys'] = key_table(ram['keys']) - disk['keys'] = key_table(disk['keys']) - total['keys'] = key_table(total['keys']) + if not is_gae: + ram['keys'] = key_table(ram['keys']) + disk['keys'] = key_table(disk['keys']) + total['keys'] = key_table(total['keys']) return dict(form=form, total=total, ram=ram, disk=disk, object_stats=hp != False) diff --git a/applications/admin/controllers/default.py b/applications/admin/controllers/default.py index 2e616459..1cebd27a 100644 --- a/applications/admin/controllers/default.py +++ b/applications/admin/controllers/default.py @@ -574,10 +574,10 @@ def edit(): # Load json only if it is ajax edited... app = get_app(request.vars.app) app_path = apath(app, r=request) - editor_defaults={'theme':'web2py', 'editor': 'default', 'closetag': 'true', 'codefolding': 'false', 'tabwidth':'4', 'indentwithtabs':'false', 'linenumbers':'true', 'highlightline':'true'} + preferences={'theme':'web2py', 'editor': 'default', 'closetag': 'true', 'codefolding': 'false', 'tabwidth':'4', 'indentwithtabs':'false', 'linenumbers':'true', 'highlightline':'true'} config = Config(os.path.join(request.folder, 'settings.cfg'), - section='editor', default_values=editor_defaults) - preferences = config.read() + section='editor', default_values={}) + preferences.update(config.read()) if not(request.ajax) and not(is_mobile): # return the scaffolding, the rest will be through ajax requests @@ -589,7 +589,7 @@ def edit(): if request.post_vars: #save new preferences post_vars = request.post_vars.items() # Since unchecked checkbox are not serialized, we must set them as false by hand to store the correct preference in the settings - post_vars+= [(opt, 'false') for opt in editor_defaults if opt not in request.post_vars ] + post_vars+= [(opt, 'false') for opt in preferences if opt not in request.post_vars ] if config.save(post_vars): response.headers["web2py-component-flash"] = T('Preferences saved correctly') else: @@ -814,6 +814,22 @@ def todolist(): return {'todo':output, 'app': app} +def editor_sessions(): + config = Config(os.path.join(request.folder, 'settings.cfg'), + section='editor_sessions', default_values={}) + preferences = config.read() + + if request.vars.session_name and request.vars.files: + session_name = request.vars.session_name + files = request.vars.files + preferences.update({session_name:','.join(files)}) + if config.save(preferences.items()): + response.headers["web2py-component-flash"] = T('Session saved correctly') + else: + response.headers["web2py-component-flash"] = T('Session saved on session only') + + return response.render('default/editor_sessions.html', {'editor_sessions':preferences}) + def resolve(): """ """ diff --git a/applications/admin/languages/es.py b/applications/admin/languages/es.py index d8c4c4ef..61cc8fa0 100644 --- a/applications/admin/languages/es.py +++ b/applications/admin/languages/es.py @@ -12,6 +12,7 @@ '(version %s)': '(version %s)', '@markmin\x01(file **gluon/contrib/plural_rules/%s.py** is not found)': '(file **gluon/contrib/plural_rules/%s.py** is not found)', '@markmin\x01An error occured, please [[reload %s]] the page': 'An error occured, please [[reload %s]] the page', +'@markmin\x01Number of entries: **%s**': 'Number of entries: **%s**', '@markmin\x01Searching: **%s** %%{file}': 'Searching: **%s** files', 'A new version of web2py is available': 'Hay una nueva versión de web2py disponible', 'A new version of web2py is available: %s': 'Hay una nueva versión de web2py disponible: %s', @@ -57,11 +58,13 @@ 'Autocomplete': 'Autocomplete', 'Autocomplete Python Code': 'Autocompletar código Python', 'Available databases and tables': 'Bases de datos y tablas disponibles', +'Available Databases and Tables': 'Available Databases and Tables', 'back': 'atrás', 'Back to the plugins list': 'Back to the plugins list', 'breakpoint': 'breakpoint', 'breakpoints': 'breakpoints', 'browse': 'buscar', +'Cache': 'Cache', 'cache': 'cache', 'cache, errors and sessions cleaned': 'cache, errores y sesiones eliminados', 'can be a git repo': 'puede ser un repositorio git', @@ -79,6 +82,9 @@ 'Check to delete': 'Marque para eliminar', 'Checking for upgrades...': 'Buscando actulizaciones...', 'Clean': 'limpiar', +'Clear CACHE?': 'Clear CACHE?', +'Clear DISK': 'Clear DISK', +'Clear RAM': 'Clear RAM', 'click here for online examples': 'haga clic aquí para ver ejemplos en línea', 'click here for the administrative interface': 'haga clic aquí para usar la interfaz administrativa', 'Click row to expand traceback': 'Click row to expand traceback', @@ -113,6 +119,7 @@ 'database': 'base de datos', 'database %s select': 'selección en base de datos %s', 'database administration': 'administración base de datos', +'Database Administration (appadmin)': 'Database Administration (appadmin)', 'Date and Time': 'Fecha y Hora', 'db': 'db', 'Debug': 'Debug', @@ -135,6 +142,7 @@ 'details': 'detalles', 'direction: ltr': 'direction: ltr', 'Disable': 'Deshabilitar', +'DISK': 'DISK', 'docs': 'docs', 'Docs': 'Docs', 'Done!': 'Done!', @@ -249,6 +257,7 @@ 'Lost Password': 'Contraseña perdida', 'manage': 'gestionar', 'Manage': 'Gestionar', +'Manage Cache': 'Manage Cache', 'merge': 'combinar', 'Models': 'Modelos', 'models': 'modelos', @@ -282,6 +291,7 @@ 'or provide application url:': 'o provea URL de la aplicación:', 'Origin': 'Origen', 'Original/Translation': 'Original/Traducción', +'Overview': 'Overview', 'Overwrite installed app': 'sobreescriba la aplicación instalada', 'Pack all': 'empaquetar todo', 'Pack compiled': 'empaquete compiladas', @@ -305,6 +315,7 @@ 'private files': 'archivos privados', 'Project Progress': 'Project Progress', 'Query:': 'Consulta:', +'RAM': 'RAM', 'Rapid Search': 'Rapid Search', 'record': 'registro', 'record does not exist': 'el registro no existe', @@ -356,6 +367,7 @@ 'Static': 'Static', 'static': 'estáticos', 'Static files': 'Archivos estáticos', +'Statistics': 'Statistics', 'step': 'step', 'stop': 'stop', 'submit': 'enviar', @@ -397,6 +409,7 @@ 'To emulate a breakpoint programatically, write:': 'To emulate a breakpoint programatically, write:', 'to use the debugger!': 'to use the debugger!', 'toggle breakpoint': 'alternar punto de ruptura', +'Toggle comment': 'Toggle comment', 'Toggle Fullscreen': 'Alternar pantalla completa', 'Traceback': 'Traceback', 'translation strings for the application': 'cadenas de caracteres de traducción para la aplicación', diff --git a/applications/admin/languages/it.py b/applications/admin/languages/it.py index c2b1b567..957a6087 100644 --- a/applications/admin/languages/it.py +++ b/applications/admin/languages/it.py @@ -1,4 +1,4 @@ -# coding: utf8 +# -*- coding: utf-8 -*- { '!langcode!': 'it', '!langname!': 'Italiano', @@ -303,6 +303,7 @@ 'to previous version.': 'torna a versione precedente', 'To create a plugin, name a file/folder plugin_[name]': 'Per creare un plugin, chiamare un file o cartella plugin_[nome]', 'toggle breakpoint': 'toggle breakpoint', +'Toggle comment': 'Toggle comment', 'Toggle Fullscreen': 'Toggle Fullscreen', 'Traceback': 'Traceback', 'translation strings for the application': "stringhe di traduzioni per l'applicazione", diff --git a/applications/admin/models/0.py b/applications/admin/models/0.py index 669ffd27..8ba7420e 100644 --- a/applications/admin/models/0.py +++ b/applications/admin/models/0.py @@ -45,4 +45,4 @@ if 'adminLanguage' in request.cookies and not (request.cookies['adminLanguage'] T.force(request.cookies['adminLanguage'].value) #set static_version -response.static_version = '2.7.3' +response.static_version = open('VERSION').read().split(' ',1)[1].split('-')[0] diff --git a/applications/admin/settings.cfg b/applications/admin/settings.cfg index a278e05f..4127b27c 100644 --- a/applications/admin/settings.cfg +++ b/applications/admin/settings.cfg @@ -1,10 +1,10 @@ [DEFAULT] -theme = web2py -closetag = true -editor = default [editor] theme = web2py editor = default closetag = true +[editor_sessions] +welcome = welcome/models/db.py,welcome/controllers/default.py,welcome/views/default/index.html + diff --git a/applications/admin/static/js/ajax_editor.js b/applications/admin/static/js/ajax_editor.js index 8a7916a4..9e002397 100644 --- a/applications/admin/static/js/ajax_editor.js +++ b/applications/admin/static/js/ajax_editor.js @@ -260,7 +260,7 @@ function load_file(url, lineno) { if(typeof (json['plain_html']) !== undefined) { if($('#' + json['id']).length === 0 || json['force'] === true) { // Create a tab and put the code in it - var tab_header = '
  • ' + json['realfilename'] + '
  • '; + var tab_header = '
  • ' + json['realfilename'] + '
  • '; var tab_body = '
    ' + json['plain_html'] + '
    '; if(json['force'] === false) { $('#myTabContent').append($(tab_body)); // First load the body diff --git a/applications/admin/static/js/web2py_bootstrap.js b/applications/admin/static/js/web2py_bootstrap.js index edcb3628..7206cb1b 100644 --- a/applications/admin/static/js/web2py_bootstrap.js +++ b/applications/admin/static/js/web2py_bootstrap.js @@ -20,14 +20,14 @@ jQuery(function(){ function hoverMenu(){ jQuery('ul.nav a.dropdown-toggle').parent().hover(function(){ adjust_height_of_collapsed_nav(); - mi = jQuery(this).addClass('open'); + var mi = jQuery(this).addClass('open'); mi.children('.dropdown-menu').stop(true, true).delay(200).fadeIn(400); }, function(){ - mi = jQuery(this); + var mi = jQuery(this); mi.children('.dropdown-menu').stop(true, true).delay(200).fadeOut(function(){mi.removeClass('open')}); }); } hoverMenu(); // first page load jQuery(window).resize(hoverMenu); // on resize event jQuery('ul.nav li.dropdown a').click(function(){window.location=jQuery(this).attr('href');}); -}); \ No newline at end of file +}); diff --git a/applications/admin/views/appadmin.html b/applications/admin/views/appadmin.html index 054efd49..7db421ee 100644 --- a/applications/admin/views/appadmin.html +++ b/applications/admin/views/appadmin.html @@ -116,13 +116,15 @@ {{elif request.function == 'ccache':}} -

    {{T("Cache")}}

    -
    - +

    {{=T("Cache")}}

    -

    {{T("Statistics")}}

    +

    {{=T("Statistics")}}

    +{{if request.env.web2py_runtime_gae:}} +{{=BEAUTIFY(total)}} +{{else:}} +

    {{=T("Overview")}}

    {{=T.M("Number of entries: **%s**", total['entries'])}}

    @@ -210,6 +212,8 @@ {{pass}}
    +{{pass}} +

    {{=T("Manage Cache")}}

    diff --git a/applications/admin/views/default/edit.html b/applications/admin/views/default/edit.html index 4e0aeac2..650752ca 100644 --- a/applications/admin/views/default/edit.html +++ b/applications/admin/views/default/edit.html @@ -208,6 +208,9 @@ $(document).on('click', 'a.font_button', function (e) {
    + +{{=LOAD('default', 'editor_sessions', ajax=True, _class='btn-group')}} + @@ -314,5 +317,28 @@ $(document).ready(function() { load_file(datum.link); $(this).val(''); }); + /* handlers to manage editor sessions + */ + $(document).on('click', '#save_session', function(e) { + e.preventDefault(); + var session_name=prompt("Session name","{{=app}}"); + + if (session_name!==null) { + files = $("[data-path]").map(function(){return $(this).data("path");}).get(); + data = JSON.stringify({ files: files, session_name:session_name}); + $.ajaxSetup({contentType: "application/json"}); + $.web2py.ajax_page("POST", "{{=URL('default', 'editor_sessions')}}", data, 'manage_sessions'); + } + }); + $(document).on('click', '#saved_sessions a[data-files]', function(e) { + e.preventDefault(); + files = $(this).data('files'); + array_files = files.split(','); + $.each(array_files, function(index, value) { + url = "{{=URL('default','edit')}}/" + value; + load_file(url); + }); + }); + diff --git a/applications/admin/views/default/editor_sessions.html b/applications/admin/views/default/editor_sessions.html new file mode 100644 index 00000000..b457b7a7 --- /dev/null +++ b/applications/admin/views/default/editor_sessions.html @@ -0,0 +1,11 @@ +
    + Saved session + +
    + diff --git a/applications/examples/controllers/appadmin.py b/applications/examples/controllers/appadmin.py index 44efa2d5..a74f0569 100644 --- a/applications/examples/controllers/appadmin.py +++ b/applications/examples/controllers/appadmin.py @@ -16,6 +16,8 @@ try: except ImportError: pgv = None +is_gae = request.env.web2py_runtime_gae or False + # ## critical --- make a copy of the environment global_env = copy.copy(globals()) @@ -359,36 +361,43 @@ def state(): def ccache(): - cache.ram.initialize() - cache.disk.initialize() + if is_gae: + form = FORM( + P(TAG.BUTTON(T("Clear CACHE?"), _type="submit", _name="yes", _value="yes"))) + else: + cache.ram.initialize() + cache.disk.initialize() - form = FORM( - P(TAG.BUTTON( - T("Clear CACHE?"), _type="submit", _name="yes", _value="yes")), - P(TAG.BUTTON( - T("Clear RAM"), _type="submit", _name="ram", _value="ram")), - P(TAG.BUTTON( - T("Clear DISK"), _type="submit", _name="disk", _value="disk")), - ) + form = FORM( + P(TAG.BUTTON( + T("Clear CACHE?"), _type="submit", _name="yes", _value="yes")), + P(TAG.BUTTON( + T("Clear RAM"), _type="submit", _name="ram", _value="ram")), + P(TAG.BUTTON( + T("Clear DISK"), _type="submit", _name="disk", _value="disk")), + ) if form.accepts(request.vars, session): - clear_ram = False - clear_disk = False session.flash = "" - if request.vars.yes: - clear_ram = clear_disk = True - if request.vars.ram: - clear_ram = True - if request.vars.disk: - clear_disk = True - - if clear_ram: - cache.ram.clear() - session.flash += T("Ram Cleared") - if clear_disk: - cache.disk.clear() - session.flash += T("Disk Cleared") - + if is_gae: + if request.vars.yes: + cache.ram.clear() + session.flash += T("Cache Cleared") + else: + clear_ram = False + clear_disk = False + if request.vars.yes: + clear_ram = clear_disk = True + if request.vars.ram: + clear_ram = True + if request.vars.disk: + clear_disk = True + if clear_ram: + cache.ram.clear() + session.flash += T("Ram Cleared") + if clear_disk: + cache.disk.clear() + session.flash += T("Disk Cleared") redirect(URL(r=request)) try: @@ -414,6 +423,7 @@ def ccache(): 'oldest': time.time(), 'keys': [] } + disk = copy.copy(ram) total = copy.copy(ram) disk['keys'] = [] @@ -428,72 +438,81 @@ def ccache(): return (hours, minutes, seconds) - for key, value in cache.ram.storage.iteritems(): - if isinstance(value, dict): - ram['hits'] = value['hit_total'] - value['misses'] - ram['misses'] = value['misses'] - try: - ram['ratio'] = ram['hits'] * 100 / value['hit_total'] - except (KeyError, ZeroDivisionError): - ram['ratio'] = 0 - else: - if hp: - ram['bytes'] += hp.iso(value[1]).size - ram['objects'] += hp.iso(value[1]).count - ram['entries'] += 1 - if value[0] < ram['oldest']: - ram['oldest'] = value[0] - ram['keys'].append((key, GetInHMS(time.time() - value[0]))) - folder = os.path.join(request.folder,'cache') - if not os.path.exists(folder): - os.mkdir(folder) - locker = open(os.path.join(folder, 'cache.lock'), 'a') - portalocker.lock(locker, portalocker.LOCK_EX) - disk_storage = shelve.open( - os.path.join(folder, 'cache.shelve')) - try: - for key, value in disk_storage.items(): + if is_gae: + gae_stats = cache.ram.client.get_stats() + try: + gae_stats['ratio'] = ((gae_stats['hits'] * 100) / + (gae_stats['hits'] + gae_stats['misses'])) + except ZeroDivisionError: + gae_stats['ratio'] = T("?") + gae_stats['oldest'] = GetInHMS(time.time() - gae_stats['oldest_item_age']) + total.update(gae_stats) + else: + for key, value in cache.ram.storage.iteritems(): if isinstance(value, dict): - disk['hits'] = value['hit_total'] - value['misses'] - disk['misses'] = value['misses'] + ram['hits'] = value['hit_total'] - value['misses'] + ram['misses'] = value['misses'] try: - disk['ratio'] = disk['hits'] * 100 / value['hit_total'] + ram['ratio'] = ram['hits'] * 100 / value['hit_total'] except (KeyError, ZeroDivisionError): - disk['ratio'] = 0 + ram['ratio'] = 0 else: if hp: - disk['bytes'] += hp.iso(value[1]).size - disk['objects'] += hp.iso(value[1]).count - disk['entries'] += 1 - if value[0] < disk['oldest']: - disk['oldest'] = value[0] - disk['keys'].append((key, GetInHMS(time.time() - value[0]))) + ram['bytes'] += hp.iso(value[1]).size + ram['objects'] += hp.iso(value[1]).count + ram['entries'] += 1 + if value[0] < ram['oldest']: + ram['oldest'] = value[0] + ram['keys'].append((key, GetInHMS(time.time() - value[0]))) + folder = os.path.join(request.folder,'cache') + if not os.path.exists(folder): + os.mkdir(folder) + locker = open(os.path.join(folder, 'cache.lock'), 'a') + portalocker.lock(locker, portalocker.LOCK_EX) + disk_storage = shelve.open( + os.path.join(folder, 'cache.shelve')) + try: + for key, value in disk_storage.items(): + if isinstance(value, dict): + disk['hits'] = value['hit_total'] - value['misses'] + disk['misses'] = value['misses'] + try: + disk['ratio'] = disk['hits'] * 100 / value['hit_total'] + except (KeyError, ZeroDivisionError): + disk['ratio'] = 0 + else: + if hp: + disk['bytes'] += hp.iso(value[1]).size + disk['objects'] += hp.iso(value[1]).count + disk['entries'] += 1 + if value[0] < disk['oldest']: + disk['oldest'] = value[0] + disk['keys'].append((key, GetInHMS(time.time() - value[0]))) + finally: + portalocker.unlock(locker) + locker.close() + disk_storage.close() - finally: - portalocker.unlock(locker) - locker.close() - disk_storage.close() - - total['entries'] = ram['entries'] + disk['entries'] - total['bytes'] = ram['bytes'] + disk['bytes'] - total['objects'] = ram['objects'] + disk['objects'] - total['hits'] = ram['hits'] + disk['hits'] - total['misses'] = ram['misses'] + disk['misses'] - total['keys'] = ram['keys'] + disk['keys'] - try: - total['ratio'] = total['hits'] * 100 / (total['hits'] + + total['entries'] = ram['entries'] + disk['entries'] + total['bytes'] = ram['bytes'] + disk['bytes'] + total['objects'] = ram['objects'] + disk['objects'] + total['hits'] = ram['hits'] + disk['hits'] + total['misses'] = ram['misses'] + disk['misses'] + total['keys'] = ram['keys'] + disk['keys'] + try: + total['ratio'] = total['hits'] * 100 / (total['hits'] + total['misses']) - except (KeyError, ZeroDivisionError): - total['ratio'] = 0 + except (KeyError, ZeroDivisionError): + total['ratio'] = 0 - if disk['oldest'] < ram['oldest']: - total['oldest'] = disk['oldest'] - else: - total['oldest'] = ram['oldest'] + if disk['oldest'] < ram['oldest']: + total['oldest'] = disk['oldest'] + else: + total['oldest'] = ram['oldest'] - ram['oldest'] = GetInHMS(time.time() - ram['oldest']) - disk['oldest'] = GetInHMS(time.time() - disk['oldest']) - total['oldest'] = GetInHMS(time.time() - total['oldest']) + ram['oldest'] = GetInHMS(time.time() - ram['oldest']) + disk['oldest'] = GetInHMS(time.time() - disk['oldest']) + total['oldest'] = GetInHMS(time.time() - total['oldest']) def key_table(keys): return TABLE( @@ -502,9 +521,10 @@ def ccache(): **dict(_class='cache-keys', _style="border-collapse: separate; border-spacing: .5em;")) - ram['keys'] = key_table(ram['keys']) - disk['keys'] = key_table(disk['keys']) - total['keys'] = key_table(total['keys']) + if not is_gae: + ram['keys'] = key_table(ram['keys']) + disk['keys'] = key_table(disk['keys']) + total['keys'] = key_table(total['keys']) return dict(form=form, total=total, ram=ram, disk=disk, object_stats=hp != False) diff --git a/applications/examples/static/js/web2py_bootstrap.js b/applications/examples/static/js/web2py_bootstrap.js index edcb3628..7206cb1b 100644 --- a/applications/examples/static/js/web2py_bootstrap.js +++ b/applications/examples/static/js/web2py_bootstrap.js @@ -20,14 +20,14 @@ jQuery(function(){ function hoverMenu(){ jQuery('ul.nav a.dropdown-toggle').parent().hover(function(){ adjust_height_of_collapsed_nav(); - mi = jQuery(this).addClass('open'); + var mi = jQuery(this).addClass('open'); mi.children('.dropdown-menu').stop(true, true).delay(200).fadeIn(400); }, function(){ - mi = jQuery(this); + var mi = jQuery(this); mi.children('.dropdown-menu').stop(true, true).delay(200).fadeOut(function(){mi.removeClass('open')}); }); } hoverMenu(); // first page load jQuery(window).resize(hoverMenu); // on resize event jQuery('ul.nav li.dropdown a').click(function(){window.location=jQuery(this).attr('href');}); -}); \ No newline at end of file +}); diff --git a/applications/examples/static/markmin.html b/applications/examples/static/markmin.html index 7919434a..a469be15 100644 --- a/applications/examples/static/markmin.html +++ b/applications/examples/static/markmin.html @@ -25,14 +25,9 @@ print markmin2html(m) from markmin2latex import markmin2latex print markmin2latex(m) from markmin2pdf import markmin2pdf # requires pdflatex -print markmin2pdf(m) ====================

    This is a test block with new features:

    This is a blockquote with a list with tables in it:

    This is a paragraph before list. You can continue paragraph on the next lines.
    This is an ordered list with tables:
    1. Item 1
    2. Item 2
    3. aabbcc
      112233
    4. Item 4
      T1T2t3
      aaabbbccc
      dddfffggg
      12305.0

    This this a new paragraph with a table. Table has header, footer, sections, odd and even rows:

    Title 1Title 2Title 3
    data 1data 22.00
    data 3data4(long)23.00
    data 533.50
    New sectionNew data5.00
    data 1data2(long)100.45
    data 312.50
    data 4data 5.33
    data 6data7(long)8.01
    data 8514
    Total:9 items698,79

    Multilevel lists

    Now lists can be multilevel:

    1. Ordered item 1 on level 1. You can continue item text on next strings
      1. Ordered item 1 of sublevel 2 with a paragraph (paragraph can start with point after plus or minus characters, e.g. ++. or --.)

      2. This is another item. But with 3 paragraphs, blockquote and sublists:

        This is the second paragraph in the item. You can add paragraphs to an item, using point notation, where first characters in the string are sequence of points with space between them and another string. For example, this paragraph (in sublevel 2) starts with two points:

        .. This is the second paragraph...

        this is a blockquote in a list

        You can use blockquote with headers, paragraphs, tables and lists in it:
        Tables can have or have not header and footer. This table is defined without any header and footer in it:
        redfox0
        bluedolphin1000
        greenleaf10000

        This is yet another paragraph in the item.

        • This is an item of unordered list (sublevel 3)
        • This is the second item of the unordered list (sublevel 3)
              1. This is a single item of ordered list in sublevel 6

            and this is a paragraph in sublevel 4

        • This is a new item with paragraph in sublevel 3.

          1. Start ordered list in sublevel 4 with code block:
            line 1
            -  line 2
            -     line 3
          2. Yet another item with code block:

              line 1
            -line 2
            -  line 3
            This item finishes with this paragraph.

          Item in sublevel 3 can be continued with paragraphs.

            this is another
          -code block
          -    in the
          -  sublevel 3 item
        1. The last item in sublevel 3

        This is a continuous paragraph for item 2 in sublevel 2. You can use such structure to create difficult structured documents.

      3. item 3 in sublevel 2
      • item 1 in sublevel 2 (new unordered list)
      • item 2 in sublevel 2
      • item 3 in sublevel 2
      1. item 1 in sublevel 2 (new ordered list)
      2. item 2 in sublevel 2
      3. item 3 in sublevle 2
    2. item 2 in level 1
    3. item 3 in level 1
    • new unordered list (item 1 in level 1)
    • level 2 in level 1
    • level 3 in level 1
    • level 4 in level 1

    This is the last section of the test

    Single paragraph with '----' in it will be turned into separator:


    And this is the last paragraph in the test. Be happy!

    ====================

    Why?

    We wanted a markup language with the following requirements:

    • less than 300 lines of functional code
    • easy to read
    • secure
    • support table, ul, ol, code
    • support html5 video and audio elements (html serialization only)
    • can align images and resize them
    • can specify class for tables and code elements
    • can add anchors
    • does not use _ for markup (since it creates odd behavior)
    • automatically links urls
    • fast
    • easy to extend
    • supports latex and pdf including references
    • allows to describe the markup in the markup (this document is generated from markmin syntax)

    (results depend on text but in average for text ~100K markmin is 30% faster than markdown, for text ~10K it is 10x faster)

    The web2py book published by lulu, for example, was entirely generated with markmin2pdf from the online web2py wiki

    Download

    markmin2html.py and markmin2latex.py are single files and have no web2py dependence. Their license is BSD.

    Examples

    Bold, italic, code and links

    SOURCEOUTPUT
    # titletitle
    ## sectionsection
    ### subsectionsubsection
    **bold**bold
    ''italic''italic
    ~~strikeout~~strikeout
    ``verbatim``verbatim
    ``color with **bold**``:redcolor with bold
    ``many colors``:color[blue:#ffff00]many colors
    http://google.comhttp://google.com
    [[**click** me #myanchor]]click me
    [[click me [extra info] #myanchor popup]]click me

    More on links

    The format is always [[title link]] or [[title [extra] link]]. Notice you can nest bold, italic, strikeout and code inside the link title.

    Anchors

    You can place an anchor anywhere in the text using the syntax [[name]] where name is the name of the anchor. You can then link the anchor with link, i.e. [[link #myanchor]] or link with an extra info, i.e. [[link with an extra info [extra info] #myanchor]].

    Images

    alt-string for the image This paragraph has an image aligned to the right with a width of 200px. Its is placed using the code

    [[alt-string for the image [the image title] http://www.web2py.com/examples/static/web2py_logo.png right 200px]].

    Unordered Lists

    - Dog
    +print markmin2pdf(m)
    + +

    Why?

    We wanted a markup language with the following requirements:

    • less than 300 lines of functional code
    • easy to read
    • secure
    • support table, ul, ol, code
    • support html5 video and audio elements (html serialization only)
    • can align images and resize them
    • can specify class for tables and code elements
    • can add anchors
    • does not use _ for markup (since it creates odd behavior)
    • automatically links urls
    • fast
    • easy to extend
    • supports latex and pdf including references
    • allows to describe the markup in the markup (this document is generated from markmin syntax)

    (results depend on text but in average for text ~100K markmin is 30% faster than markdown, for text ~10K it is 10x faster)

    The web2py book published by lulu, for example, was entirely generated with markmin2pdf from the online web2py wiki

    Download

    markmin2html.py and markmin2latex.py are single files and have no web2py dependence. Their license is BSD.

    Examples

    Bold, italic, code and links

    SOURCEOUTPUT
    # titletitle
    ## sectionsection
    ### subsectionsubsection
    **bold**bold
    ''italic''italic
    ~~strikeout~~strikeout
    ``verbatim``verbatim
    ``color with **bold**``:redcolor with bold
    ``many colors``:color[blue:#ffff00]many colors
    http://google.comhttp://google.com
    [[**click** me #myanchor]]click me
    [[click me [extra info] #myanchor popup]]click me

    More on links

    The format is always [[title link]] or [[title [extra] link]]. Notice you can nest bold, italic, strikeout and code inside the link title.

    Anchors

    You can place an anchor anywhere in the text using the syntax [[name]] where name is the name of the anchor. You can then link the anchor with link, i.e. [[link #myanchor]] or link with an extra info, i.e. [[link with an extra info [extra info] #myanchor]].

    Images

    alt-string for the image This paragraph has an image aligned to the right with a width of 200px. Its is placed using the code

    [[alt-string for the image [the image title] http://www.web2py.com/examples/static/web2py_logo.png right 200px]].

    Unordered Lists

    - Dog
     - Cat
     - Mouse

    is rendered as

    • Dog
    • Cat
    • Mouse

    Two new lines between items break the list in two lists.

    Ordered Lists

    + Dog
     + Cat
    @@ -85,6 +80,15 @@ markmin2html(text,{'latex':lambda code: LATEX % code.replace('"','\"')})<
     <html><body>example</body></html>
     ``:code[html]

    Citations and References

    Citations are treated as internal links in html and proper citations in latex if there is a final section called "References". Items like

    - [[key]] value

    in the References will be translated into Latex

    \bibitem{key} value

    Here is an example of usage:

    As shown in Ref.``mdipierro``:cite
     
    +

    This is a test block with new features:

    This is a blockquote with a list with tables in it:

    This is a paragraph before list. You can continue paragraph on the next lines.
    This is an ordered list with tables:
    1. Item 1
    2. Item 2
    3. aabbcc
      112233
    4. Item 4
      T1T2t3
      aaabbbccc
      dddfffggg
      12305.0

    This this a new paragraph with a table. Table has header, footer, sections, odd and even rows:

    Title 1Title 2Title 3
    data 1data 22.00
    data 3data4(long)23.00
    data 533.50
    New sectionNew data5.00
    data 1data2(long)100.45
    data 312.50
    data 4data 5.33
    data 6data7(long)8.01
    data 8514
    Total:9 items698,79

    Multilevel lists

    Now lists can be multilevel:

    1. Ordered item 1 on level 1. You can continue item text on next strings
      1. Ordered item 1 of sublevel 2 with a paragraph (paragraph can start with point after plus or minus characters, e.g. ++. or --.)

      2. This is another item. But with 3 paragraphs, blockquote and sublists:

        This is the second paragraph in the item. You can add paragraphs to an item, using point notation, where first characters in the string are sequence of points with space between them and another string. For example, this paragraph (in sublevel 2) starts with two points:

        .. This is the second paragraph...

        this is a blockquote in a list

        You can use blockquote with headers, paragraphs, tables and lists in it:
        Tables can have or have not header and footer. This table is defined without any header and footer in it:
        redfox0
        bluedolphin1000
        greenleaf10000

        This is yet another paragraph in the item.

        • This is an item of unordered list (sublevel 3)
        • This is the second item of the unordered list (sublevel 3)
              1. This is a single item of ordered list in sublevel 6

            and this is a paragraph in sublevel 4

        • This is a new item with paragraph in sublevel 3.

          1. Start ordered list in sublevel 4 with code block:
            line 1
            +  line 2
            +     line 3
          2. Yet another item with code block:

              line 1
            +line 2
            +  line 3
            This item finishes with this paragraph.

          Item in sublevel 3 can be continued with paragraphs.

            this is another
          +code block
          +    in the
          +  sublevel 3 item
        1. The last item in sublevel 3

        This is a continuous paragraph for item 2 in sublevel 2. You can use such structure to create difficult structured documents.

      3. item 3 in sublevel 2
      • item 1 in sublevel 2 (new unordered list)
      • item 2 in sublevel 2
      • item 3 in sublevel 2
      1. item 1 in sublevel 2 (new ordered list)
      2. item 2 in sublevel 2
      3. item 3 in sublevle 2
    2. item 2 in level 1
    3. item 3 in level 1
    • new unordered list (item 1 in level 1)
    • level 2 in level 1
    • level 3 in level 1
    • level 4 in level 1

    This is the last section of the test

    Single paragraph with '----' in it will be turned into separator:


    And this is the last paragraph in the test. Be happy!

    + ## References - [[mdipierro]] web2py Manual, 5th Edition, lulu.com

    Caveats

    <ul/>, <ol/>, <code/>, <table/>, <blockquote/>, <h1/>, ..., <h6/> do not have <p>...</p> around them.

    diff --git a/applications/examples/views/appadmin.html b/applications/examples/views/appadmin.html index 054efd49..7db421ee 100644 --- a/applications/examples/views/appadmin.html +++ b/applications/examples/views/appadmin.html @@ -116,13 +116,15 @@ {{elif request.function == 'ccache':}} -

    {{T("Cache")}}

    -
    - +

    {{=T("Cache")}}

    -

    {{T("Statistics")}}

    +

    {{=T("Statistics")}}

    +{{if request.env.web2py_runtime_gae:}} +{{=BEAUTIFY(total)}} +{{else:}} +

    {{=T("Overview")}}

    {{=T.M("Number of entries: **%s**", total['entries'])}}

    @@ -210,6 +212,8 @@ {{pass}}
    +{{pass}} +

    {{=T("Manage Cache")}}

    diff --git a/applications/welcome/controllers/appadmin.py b/applications/welcome/controllers/appadmin.py index 44efa2d5..a74f0569 100644 --- a/applications/welcome/controllers/appadmin.py +++ b/applications/welcome/controllers/appadmin.py @@ -16,6 +16,8 @@ try: except ImportError: pgv = None +is_gae = request.env.web2py_runtime_gae or False + # ## critical --- make a copy of the environment global_env = copy.copy(globals()) @@ -359,36 +361,43 @@ def state(): def ccache(): - cache.ram.initialize() - cache.disk.initialize() + if is_gae: + form = FORM( + P(TAG.BUTTON(T("Clear CACHE?"), _type="submit", _name="yes", _value="yes"))) + else: + cache.ram.initialize() + cache.disk.initialize() - form = FORM( - P(TAG.BUTTON( - T("Clear CACHE?"), _type="submit", _name="yes", _value="yes")), - P(TAG.BUTTON( - T("Clear RAM"), _type="submit", _name="ram", _value="ram")), - P(TAG.BUTTON( - T("Clear DISK"), _type="submit", _name="disk", _value="disk")), - ) + form = FORM( + P(TAG.BUTTON( + T("Clear CACHE?"), _type="submit", _name="yes", _value="yes")), + P(TAG.BUTTON( + T("Clear RAM"), _type="submit", _name="ram", _value="ram")), + P(TAG.BUTTON( + T("Clear DISK"), _type="submit", _name="disk", _value="disk")), + ) if form.accepts(request.vars, session): - clear_ram = False - clear_disk = False session.flash = "" - if request.vars.yes: - clear_ram = clear_disk = True - if request.vars.ram: - clear_ram = True - if request.vars.disk: - clear_disk = True - - if clear_ram: - cache.ram.clear() - session.flash += T("Ram Cleared") - if clear_disk: - cache.disk.clear() - session.flash += T("Disk Cleared") - + if is_gae: + if request.vars.yes: + cache.ram.clear() + session.flash += T("Cache Cleared") + else: + clear_ram = False + clear_disk = False + if request.vars.yes: + clear_ram = clear_disk = True + if request.vars.ram: + clear_ram = True + if request.vars.disk: + clear_disk = True + if clear_ram: + cache.ram.clear() + session.flash += T("Ram Cleared") + if clear_disk: + cache.disk.clear() + session.flash += T("Disk Cleared") redirect(URL(r=request)) try: @@ -414,6 +423,7 @@ def ccache(): 'oldest': time.time(), 'keys': [] } + disk = copy.copy(ram) total = copy.copy(ram) disk['keys'] = [] @@ -428,72 +438,81 @@ def ccache(): return (hours, minutes, seconds) - for key, value in cache.ram.storage.iteritems(): - if isinstance(value, dict): - ram['hits'] = value['hit_total'] - value['misses'] - ram['misses'] = value['misses'] - try: - ram['ratio'] = ram['hits'] * 100 / value['hit_total'] - except (KeyError, ZeroDivisionError): - ram['ratio'] = 0 - else: - if hp: - ram['bytes'] += hp.iso(value[1]).size - ram['objects'] += hp.iso(value[1]).count - ram['entries'] += 1 - if value[0] < ram['oldest']: - ram['oldest'] = value[0] - ram['keys'].append((key, GetInHMS(time.time() - value[0]))) - folder = os.path.join(request.folder,'cache') - if not os.path.exists(folder): - os.mkdir(folder) - locker = open(os.path.join(folder, 'cache.lock'), 'a') - portalocker.lock(locker, portalocker.LOCK_EX) - disk_storage = shelve.open( - os.path.join(folder, 'cache.shelve')) - try: - for key, value in disk_storage.items(): + if is_gae: + gae_stats = cache.ram.client.get_stats() + try: + gae_stats['ratio'] = ((gae_stats['hits'] * 100) / + (gae_stats['hits'] + gae_stats['misses'])) + except ZeroDivisionError: + gae_stats['ratio'] = T("?") + gae_stats['oldest'] = GetInHMS(time.time() - gae_stats['oldest_item_age']) + total.update(gae_stats) + else: + for key, value in cache.ram.storage.iteritems(): if isinstance(value, dict): - disk['hits'] = value['hit_total'] - value['misses'] - disk['misses'] = value['misses'] + ram['hits'] = value['hit_total'] - value['misses'] + ram['misses'] = value['misses'] try: - disk['ratio'] = disk['hits'] * 100 / value['hit_total'] + ram['ratio'] = ram['hits'] * 100 / value['hit_total'] except (KeyError, ZeroDivisionError): - disk['ratio'] = 0 + ram['ratio'] = 0 else: if hp: - disk['bytes'] += hp.iso(value[1]).size - disk['objects'] += hp.iso(value[1]).count - disk['entries'] += 1 - if value[0] < disk['oldest']: - disk['oldest'] = value[0] - disk['keys'].append((key, GetInHMS(time.time() - value[0]))) + ram['bytes'] += hp.iso(value[1]).size + ram['objects'] += hp.iso(value[1]).count + ram['entries'] += 1 + if value[0] < ram['oldest']: + ram['oldest'] = value[0] + ram['keys'].append((key, GetInHMS(time.time() - value[0]))) + folder = os.path.join(request.folder,'cache') + if not os.path.exists(folder): + os.mkdir(folder) + locker = open(os.path.join(folder, 'cache.lock'), 'a') + portalocker.lock(locker, portalocker.LOCK_EX) + disk_storage = shelve.open( + os.path.join(folder, 'cache.shelve')) + try: + for key, value in disk_storage.items(): + if isinstance(value, dict): + disk['hits'] = value['hit_total'] - value['misses'] + disk['misses'] = value['misses'] + try: + disk['ratio'] = disk['hits'] * 100 / value['hit_total'] + except (KeyError, ZeroDivisionError): + disk['ratio'] = 0 + else: + if hp: + disk['bytes'] += hp.iso(value[1]).size + disk['objects'] += hp.iso(value[1]).count + disk['entries'] += 1 + if value[0] < disk['oldest']: + disk['oldest'] = value[0] + disk['keys'].append((key, GetInHMS(time.time() - value[0]))) + finally: + portalocker.unlock(locker) + locker.close() + disk_storage.close() - finally: - portalocker.unlock(locker) - locker.close() - disk_storage.close() - - total['entries'] = ram['entries'] + disk['entries'] - total['bytes'] = ram['bytes'] + disk['bytes'] - total['objects'] = ram['objects'] + disk['objects'] - total['hits'] = ram['hits'] + disk['hits'] - total['misses'] = ram['misses'] + disk['misses'] - total['keys'] = ram['keys'] + disk['keys'] - try: - total['ratio'] = total['hits'] * 100 / (total['hits'] + + total['entries'] = ram['entries'] + disk['entries'] + total['bytes'] = ram['bytes'] + disk['bytes'] + total['objects'] = ram['objects'] + disk['objects'] + total['hits'] = ram['hits'] + disk['hits'] + total['misses'] = ram['misses'] + disk['misses'] + total['keys'] = ram['keys'] + disk['keys'] + try: + total['ratio'] = total['hits'] * 100 / (total['hits'] + total['misses']) - except (KeyError, ZeroDivisionError): - total['ratio'] = 0 + except (KeyError, ZeroDivisionError): + total['ratio'] = 0 - if disk['oldest'] < ram['oldest']: - total['oldest'] = disk['oldest'] - else: - total['oldest'] = ram['oldest'] + if disk['oldest'] < ram['oldest']: + total['oldest'] = disk['oldest'] + else: + total['oldest'] = ram['oldest'] - ram['oldest'] = GetInHMS(time.time() - ram['oldest']) - disk['oldest'] = GetInHMS(time.time() - disk['oldest']) - total['oldest'] = GetInHMS(time.time() - total['oldest']) + ram['oldest'] = GetInHMS(time.time() - ram['oldest']) + disk['oldest'] = GetInHMS(time.time() - disk['oldest']) + total['oldest'] = GetInHMS(time.time() - total['oldest']) def key_table(keys): return TABLE( @@ -502,9 +521,10 @@ def ccache(): **dict(_class='cache-keys', _style="border-collapse: separate; border-spacing: .5em;")) - ram['keys'] = key_table(ram['keys']) - disk['keys'] = key_table(disk['keys']) - total['keys'] = key_table(total['keys']) + if not is_gae: + ram['keys'] = key_table(ram['keys']) + disk['keys'] = key_table(disk['keys']) + total['keys'] = key_table(total['keys']) return dict(form=form, total=total, ram=ram, disk=disk, object_stats=hp != False) diff --git a/applications/welcome/languages/es.py b/applications/welcome/languages/es.py index 1e757cc9..c63ac9a2 100644 --- a/applications/welcome/languages/es.py +++ b/applications/welcome/languages/es.py @@ -1,4 +1,4 @@ -# coding: utf-8 +# -*- coding: utf-8 -*- { '!langcode!': 'es', '!langname!': 'Español', @@ -10,6 +10,7 @@ '%Y-%m-%d %H:%M:%S': '%d/%m/%Y %H:%M:%S', '(something like "it-it")': '(algo como "eso-eso")', '@markmin\x01An error occured, please [[reload %s]] the page': 'Ha ocurrido un error, por favor [[recargar %s]] la página', +'@markmin\x01Number of entries: **%s**': 'Number of entries: **%s**', 'A new version of web2py is available': 'Hay una nueva versión de web2py disponible', 'A new version of web2py is available: %s': 'Hay una nueva versión de web2py disponible: %s', 'About': 'Acerca de', @@ -91,6 +92,7 @@ 'Database': 'Base de datos', 'Database %s select': 'selección en base de datos %s', 'database administration': 'administración base de datos', +'Database Administration (appadmin)': 'Database Administration (appadmin)', 'Date and Time': 'Fecha y Hora', 'db': 'bdd', 'DB Model': 'Modelo BDD', diff --git a/applications/welcome/static/css/web2py.css b/applications/welcome/static/css/web2py.css index 30d97035..dfba3fdd 100644 --- a/applications/welcome/static/css/web2py.css +++ b/applications/welcome/static/css/web2py.css @@ -36,7 +36,7 @@ audio {width:200px} .hidden {display:none;visibility:visible} .right {float:right; text-align:right} .left {float:left; text-align:left} -.center {width:100; text-align:center; vertical-align:middle} +.center {width:100%; text-align:center; vertical-align:middle} /** end **/ /* Sticky footer begin */ diff --git a/applications/welcome/static/js/web2py_bootstrap.js b/applications/welcome/static/js/web2py_bootstrap.js index edcb3628..7206cb1b 100644 --- a/applications/welcome/static/js/web2py_bootstrap.js +++ b/applications/welcome/static/js/web2py_bootstrap.js @@ -20,14 +20,14 @@ jQuery(function(){ function hoverMenu(){ jQuery('ul.nav a.dropdown-toggle').parent().hover(function(){ adjust_height_of_collapsed_nav(); - mi = jQuery(this).addClass('open'); + var mi = jQuery(this).addClass('open'); mi.children('.dropdown-menu').stop(true, true).delay(200).fadeIn(400); }, function(){ - mi = jQuery(this); + var mi = jQuery(this); mi.children('.dropdown-menu').stop(true, true).delay(200).fadeOut(function(){mi.removeClass('open')}); }); } hoverMenu(); // first page load jQuery(window).resize(hoverMenu); // on resize event jQuery('ul.nav li.dropdown a').click(function(){window.location=jQuery(this).attr('href');}); -}); \ No newline at end of file +}); diff --git a/applications/welcome/views/appadmin.html b/applications/welcome/views/appadmin.html index 054efd49..7db421ee 100644 --- a/applications/welcome/views/appadmin.html +++ b/applications/welcome/views/appadmin.html @@ -116,13 +116,15 @@ {{elif request.function == 'ccache':}} -

    {{T("Cache")}}

    -
    - +

    {{=T("Cache")}}

    -

    {{T("Statistics")}}

    +

    {{=T("Statistics")}}

    +{{if request.env.web2py_runtime_gae:}} +{{=BEAUTIFY(total)}} +{{else:}} +

    {{=T("Overview")}}

    {{=T.M("Number of entries: **%s**", total['entries'])}}

    @@ -210,6 +212,8 @@ {{pass}}
    +{{pass}} +

    {{=T("Manage Cache")}}

    diff --git a/examples/routes.parametric.example.py b/examples/routes.parametric.example.py index 714a5a0a..9518ed46 100644 --- a/examples/routes.parametric.example.py +++ b/examples/routes.parametric.example.py @@ -48,9 +48,11 @@ # default_language # The language code (for example: en, it-it) optionally appears in the URL following # the application (which may be omitted). For incoming URLs, the code is copied to -# request.language; for outgoing URLs it is taken from request.language. +# request.uri_language; for outgoing URLs it is taken from request.uri_language. # If languages=None, language support is disabled. # The default_language, if any, is omitted from the URL. +# To use the incoming language in your application, add this line to one of your models files: +# if request.uri_language: T.force(request.uri_language) # root_static: list of static files accessed from root (by default, favicon.ico & robots.txt) # (mapped to the default application's static/ directory) # Each default (including domain-mapped) application has its own root-static files. diff --git a/gluon/compileapp.py b/gluon/compileapp.py index d0f5bc10..cec75ea2 100644 --- a/gluon/compileapp.py +++ b/gluon/compileapp.py @@ -528,7 +528,7 @@ def run_models_in(environment): models_to_run = None for model in models: if response.models_to_run != models_to_run: - regex = models_to_run = response.models_to_run + regex = models_to_run = response.models_to_run[:] if isinstance(regex, list): regex = re_compile('|'.join(regex)) if models_to_run: diff --git a/gluon/contrib/login_methods/rpx_account.py b/gluon/contrib/login_methods/rpx_account.py index 0cd1c56a..d8c47eb6 100644 --- a/gluon/contrib/login_methods/rpx_account.py +++ b/gluon/contrib/login_methods/rpx_account.py @@ -98,27 +98,32 @@ class RPXAccount(object): def login_form(self): request = self.request args = request.args - if self.embed: - JANRAIN_URL = \ - "https://%s.rpxnow.com/openid/embed?token_url=%s&language_preference=%s" - rpxform = IFRAME( - _src=JANRAIN_URL % ( - self.domain, self.token_url, self.language), - _scrolling="no", - _frameborder="no", - _style="width:400px;height:240px;") - else: - JANRAIN_URL = \ - "https://%s.rpxnow.com/openid/v2/signin?token_url=%s" - rpxform = DIV(SCRIPT(_src="https://rpxnow.com/openid/v2/widget", - _type="text/javascript"), - SCRIPT("RPXNOW.overlay = true;", - "RPXNOW.language_preference = '%s';" % self.language, - "RPXNOW.realm = '%s';" % self.domain, - "RPXNOW.token_url = '%s';" % self.token_url, - "RPXNOW.show();", - _type="text/javascript")) - return rpxform + rpxform = """ + +
    """ % (self.token_url, self.domain, self.domain) + return XML(rpxform) def use_janrain(auth, filename='private/janrain.key', **kwargs): diff --git a/gluon/contrib/populate.py b/gluon/contrib/populate.py index 122a4d64..2930d119 100644 --- a/gluon/contrib/populate.py +++ b/gluon/contrib/populate.py @@ -266,5 +266,5 @@ def populate_generator(table, default=True, compute=False, contents={}): if __name__ == '__main__': ell = Learner() - ell.loadd(eval(IUP)) + ell.loadd(IUP) print ell.generate(1000, prefix=None) diff --git a/gluon/dal.py b/gluon/dal.py index 3d7b33d2..2ac4c8b6 100644 --- a/gluon/dal.py +++ b/gluon/dal.py @@ -8189,8 +8189,8 @@ def index(): limits = (offset,long(vars.get('limit',None) or 1000)+offset) except ValueError: return Row({'status':400,'error':'invalid limits','response':None}) - if count > limits[1]-limits[0]: - return Row({'status':400,'error':'too many records','response':None}) + #if count > limits[1]-limits[0]: + # return Row({'status':400,'error':'too many records','response':None}) try: response = dbset.select(limitby=limits,orderby=orderby,*fields) except ValueError: @@ -8453,6 +8453,9 @@ def index(): columns = adapter.cursor.description # reduce the column info down to just the field names fields = colnames or [f[0] for f in columns] + if len(fields) != len(set(fields)): + raise RuntimeError("Result set includes duplicate column names. Specify unique column names using the 'colnames' argument") + # will hold our finished resultset in a list data = adapter._fetchall() # convert the list for each row into a dictionary so it's diff --git a/gluon/sqlhtml.py b/gluon/sqlhtml.py index 2a417c78..9bc86c4e 100644 --- a/gluon/sqlhtml.py +++ b/gluon/sqlhtml.py @@ -3204,7 +3204,8 @@ class ExporterHTML(ExportClass): ExportClass.__init__(self, rows) def export(self): - return '\n\n\n\n\n%s\n\n' % (self.rows.xml() or '') + xml = self.rows.xml() if self.rows else '' + return '\n\n\n\n\n%s\n\n' % (xml or '') class ExporterXML(ExportClass): label = 'XML' diff --git a/gluon/tools.py b/gluon/tools.py index b0d4d3a5..0dbecb1e 100644 --- a/gluon/tools.py +++ b/gluon/tools.py @@ -2112,7 +2112,7 @@ class Auth(object): success = False if row: userfield = self.settings.login_userfield or 'username' \ - if 'username' in table_user.fields else 'email' + if 'username' in table.fields else 'email' # If ticket is a service Ticket and RENEW flag respected if ticket[0:3] == 'ST-' and \ not ((row.renew and renew) ^ renew): @@ -5893,7 +5893,7 @@ class Wiki(object): class Config(object): def __init__( self, - filename, + filename, section, default_values={} ): diff --git a/gluon/validators.py b/gluon/validators.py index 0107e43a..1bf11af4 100644 --- a/gluon/validators.py +++ b/gluon/validators.py @@ -458,7 +458,7 @@ class IS_IN_SET(Validator): regex1 = re.compile('\w+\.\w+') -regex2 = re.compile('%\((?P[^\)]+)\)s') +regex2 = re.compile('%\((?P[^\)]+)\)(\d*\.\d*)?[a-zA-Z]') class IS_IN_DB(Validator):