From 00b51227a07bafb4e7cbd28d1cf90312eddd2413 Mon Sep 17 00:00:00 2001 From: Massimo Di Pierro Date: Fri, 3 Feb 2012 11:29:43 -0600 Subject: [PATCH] mega patch, text corrections, improved web2py.js, thanks Anthony --- VERSION | 2 +- applications/admin/static/js/web2py.js | 31 ++++++++++++------- .../en/default/documentation/more.markmin | 6 ++-- .../en/default/documentation/official.markmin | 2 ++ .../content/en/default/what/whyweb2py.markmin | 2 +- applications/examples/static/css/examples.css | 2 +- applications/examples/static/js/web2py.js | 31 ++++++++++++------- .../examples/views/default/index.html | 2 +- applications/examples/views/layout.html | 2 +- applications/welcome/static/js/web2py.js | 31 ++++++++++++------- gluon/__init__.py | 11 +++++++ gluon/dal.py | 2 +- 12 files changed, 82 insertions(+), 42 deletions(-) diff --git a/VERSION b/VERSION index 3fd96e9b..4f0d04a4 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -Version 1.99.4 (2012-02-02 16:35:38) stable +Version 1.99.4 (2012-02-03 11:29:23) stable diff --git a/applications/admin/static/js/web2py.js b/applications/admin/static/js/web2py.js index ec9599fc..64b0f3a1 100644 --- a/applications/admin/static/js/web2py.js +++ b/applications/admin/static/js/web2py.js @@ -23,10 +23,6 @@ function ajax(u,s,t) { String.prototype.reverse = function () { return this.split('').reverse().join('');}; function web2py_ajax_fields(target) { - jQuery('input.integer', target).keyup(function(){this.value=this.value.reverse().replace(/[^0-9\-]|\-(?=.)/g,'').reverse();}); - jQuery('input.double,input.decimal', target).keyup(function(){this.value=this.value.reverse().replace(/[^0-9\-\.,]|[\-](?=.)|[\.,](?=[0-9]*[\.,])/g,'').reverse();}); - var confirm_message = (typeof w2p_ajax_confirm_message != 'undefined') ? w2p_ajax_confirm_message : "Are you sure you want to delete this object?"; - jQuery("input[type='checkbox'].delete", target).live('click',function(){ if(this.checked) if(!confirm(confirm_message)) this.checked=false; }); var date_format = (typeof w2p_ajax_date_format != 'undefined') ? w2p_ajax_date_format : "%Y-%m-%d"; var datetime_format = (typeof w2p_ajax_datetime_format != 'undefined') ? w2p_ajax_datetime_format : "%Y-%m-%d %H:%M:%S"; jQuery("input.date",target).each(function() {Calendar.setup({inputField:this, ifFormat:date_format, showsTime:false });}); @@ -38,17 +34,26 @@ function web2py_ajax_fields(target) { function web2py_ajax_init(target) { jQuery('.hidden', target).hide(); jQuery('.error', target).hide().slideDown('slow'); - jQuery('.flash', target).click(function(e) { jQuery(this).fadeOut('slow'); e.preventDefault(); }); - // jQuery('input[type=submit]').click(function(){var t=jQuery(this);t.hide();t.after('')}); web2py_ajax_fields(target); }; +function web2py_event_handlers() { + var doc = jQuery(document) + doc.on('click', '.flash', function(e){jQuery(this).fadeOut('slow'); e.preventDefault();}); + doc.on('keyup', 'input.integer', function(){this.value=this.value.reverse().replace(/[^0-9\-]|\-(?=.)/g,'').reverse();}); + doc.on('keyup', 'input.double, input.decimal', function(){this.value=this.value.reverse().replace(/[^0-9\-\.,]|[\-](?=.)|[\.,](?=[0-9]*[\.,])/g,'').reverse();}); + var confirm_message = (typeof w2p_ajax_confirm_message != 'undefined') ? w2p_ajax_confirm_message : "Are you sure you want to delete this object?"; + doc.on('click', "input[type='checkbox'].delete", function(){if(this.checked) if(!confirm(confirm_message)) this.checked=false;}); +}; + jQuery(function() { var flash = jQuery('.flash'); flash.hide(); if(flash.html()) flash.slideDown(); web2py_ajax_init(document); + web2py_event_handlers(); }); + function web2py_trap_form(action,target) { jQuery('#'+target+' form').each(function(i){ var form=jQuery(this); @@ -60,6 +65,7 @@ function web2py_trap_form(action,target) { }); }); } + function web2py_trap_link(target) { jQuery('#'+target+' a.w2p_trap').each(function(i){ var link=jQuery(this); @@ -70,11 +76,12 @@ function web2py_trap_link(target) { }); }); } -function web2py_ajax_page(method,action,data,target) { - jQuery.ajax({'type':method,'url':action,'data':data, + +function web2py_ajax_page(method, action, data, target) { + jQuery.ajax({'type':method, 'url':action, 'data':data, 'beforeSend':function(xhr) { - xhr.setRequestHeader('web2py-component-location',document.location); - xhr.setRequestHeader('web2py-component-element',target);}, + xhr.setRequestHeader('web2py-component-location', document.location); + xhr.setRequestHeader('web2py-component-element', target);}, 'complete':function(xhr,text){ var html=xhr.responseText; var content=xhr.getResponseHeader('web2py-component-content'); @@ -94,9 +101,11 @@ function web2py_ajax_page(method,action,data,target) { } }); } + function web2py_component(action,target) { - jQuery(function(){ web2py_ajax_page('get',action,null,target); }); + jQuery(function(){web2py_ajax_page('get',action,null,target);}); } + function web2py_comet(url,onmessage,onopen,onclose) { if ("WebSocket" in window) { var ws = new WebSocket(url); diff --git a/applications/examples/private/content/en/default/documentation/more.markmin b/applications/examples/private/content/en/default/documentation/more.markmin index 81a55093..854e076d 100644 --- a/applications/examples/private/content/en/default/documentation/more.markmin +++ b/applications/examples/private/content/en/default/documentation/more.markmin @@ -6,9 +6,9 @@ - [[Twitter http://twitter.com/#!/web2py]] - [[User Voice http://web2py.uservoice.com/ popup]] -#### Learning -- [[Interactive Demo http://www.web2py.com/demo_admin popup]] -- [[Quick Examples http://www.web2py.com/examples/default/examples]] +#### Learning and Demos +- [[Admin Demo http://www.web2py.com/demo_admin popup]] (web-based IDE) +- [[Welcome App Demo http://www.web2py.com/welcome]] (scaffolding application) - [[Videos http://www.web2py.com/examples/default/videos/]] - [[FAQ http://www.web2py.com/AlterEgo popup]] diff --git a/applications/examples/private/content/en/default/documentation/official.markmin b/applications/examples/private/content/en/default/documentation/official.markmin index 45dd1dbe..76303290 100644 --- a/applications/examples/private/content/en/default/documentation/official.markmin +++ b/applications/examples/private/content/en/default/documentation/official.markmin @@ -3,5 +3,7 @@ - [[**web2py Online Book (english)** http://web2py.com/book popup]] - [[web2py Online Book (spanish) http://www.latinuxpress.com/books/drafts/web2py/ popup]] - [[Buy E-book/Printed Version http://stores.lulu.com/web2py popup]] +- [[web2py Application Development Cookbook http://www.packtpub.com/web2py-application-development-recipes-to-master-python-web-framework-cookbook/book?utm_source=web2py.com&utm_medium=link&utm_content=pod&utm_campaign=mdb_009617]] +- [[Quick Examples http://www.web2py.com/examples/default/examples]] - [[API http://web2py.com/book/default/chapter/04#API popup]] - [[Epydoc (source code documentation) http://www.web2py.com/examples/static/epydoc/index.html popup]] diff --git a/applications/examples/private/content/en/default/what/whyweb2py.markmin b/applications/examples/private/content/en/default/what/whyweb2py.markmin index bb323fed..7f68bc0c 100644 --- a/applications/examples/private/content/en/default/what/whyweb2py.markmin +++ b/applications/examples/private/content/en/default/what/whyweb2py.markmin @@ -9,7 +9,7 @@ - **Secure** [[It prevents the most common types of vulnerabilities http://web2py.com/examples/default/security]] including Cross Site Scripting, Injection Flaws, and Malicious File Execution. - **Enforces good Software Engineering practices** (Model-View-Controller design, Server-side form validation, postbacks) that make the code more readable, scalable, and maintainable. - **Speaks multiple protocols** HTML/XML, RSS/ATOM, RTF, PDF, JSON, AJAX, XML-RPC, CSV, REST, WIKI, Flash/AMF, and Linked Data (RDF). -- **Includes** a SSL-enabled and streaming-capable web server, a relational database, a web-based integrated development environment and web-based management interface, a Database Abstraction Layer that writes SQL for you in real time, internationalization support, multiple authentication methods, role based access control, an error logging and ticketing system, multiple caching methods for scalability, the jQuery library for AJAX and effects. +- **Includes** an SSL-enabled and streaming-capable web server, a relational database, a web-based integrated development environment and web-based management interface, a Database Abstraction Layer that writes SQL for you in real time, internationalization support, multiple authentication methods, role based access control, an error logging and ticketing system, multiple caching methods for scalability, the jQuery library for AJAX and effects, and a [[scaffolding application http://www.web2py.com/welcome]] to jumpstart development. The best way to understand web2py is to try it. You can try it online [[here http://www.web2py.com/demo_admin]] (this online version is identical to the actual web2py although some functions are disabled for security reasons). diff --git a/applications/examples/static/css/examples.css b/applications/examples/static/css/examples.css index 32d71724..707211b6 100644 --- a/applications/examples/static/css/examples.css +++ b/applications/examples/static/css/examples.css @@ -37,7 +37,7 @@ sup { line-height: 2em; vertical-align: top; } -ul { list-style: circle outside;} +ul { list-style: circle outside; padding-left: 30px;} .frame { border: 3px solid #959595; diff --git a/applications/examples/static/js/web2py.js b/applications/examples/static/js/web2py.js index ec9599fc..64b0f3a1 100644 --- a/applications/examples/static/js/web2py.js +++ b/applications/examples/static/js/web2py.js @@ -23,10 +23,6 @@ function ajax(u,s,t) { String.prototype.reverse = function () { return this.split('').reverse().join('');}; function web2py_ajax_fields(target) { - jQuery('input.integer', target).keyup(function(){this.value=this.value.reverse().replace(/[^0-9\-]|\-(?=.)/g,'').reverse();}); - jQuery('input.double,input.decimal', target).keyup(function(){this.value=this.value.reverse().replace(/[^0-9\-\.,]|[\-](?=.)|[\.,](?=[0-9]*[\.,])/g,'').reverse();}); - var confirm_message = (typeof w2p_ajax_confirm_message != 'undefined') ? w2p_ajax_confirm_message : "Are you sure you want to delete this object?"; - jQuery("input[type='checkbox'].delete", target).live('click',function(){ if(this.checked) if(!confirm(confirm_message)) this.checked=false; }); var date_format = (typeof w2p_ajax_date_format != 'undefined') ? w2p_ajax_date_format : "%Y-%m-%d"; var datetime_format = (typeof w2p_ajax_datetime_format != 'undefined') ? w2p_ajax_datetime_format : "%Y-%m-%d %H:%M:%S"; jQuery("input.date",target).each(function() {Calendar.setup({inputField:this, ifFormat:date_format, showsTime:false });}); @@ -38,17 +34,26 @@ function web2py_ajax_fields(target) { function web2py_ajax_init(target) { jQuery('.hidden', target).hide(); jQuery('.error', target).hide().slideDown('slow'); - jQuery('.flash', target).click(function(e) { jQuery(this).fadeOut('slow'); e.preventDefault(); }); - // jQuery('input[type=submit]').click(function(){var t=jQuery(this);t.hide();t.after('')}); web2py_ajax_fields(target); }; +function web2py_event_handlers() { + var doc = jQuery(document) + doc.on('click', '.flash', function(e){jQuery(this).fadeOut('slow'); e.preventDefault();}); + doc.on('keyup', 'input.integer', function(){this.value=this.value.reverse().replace(/[^0-9\-]|\-(?=.)/g,'').reverse();}); + doc.on('keyup', 'input.double, input.decimal', function(){this.value=this.value.reverse().replace(/[^0-9\-\.,]|[\-](?=.)|[\.,](?=[0-9]*[\.,])/g,'').reverse();}); + var confirm_message = (typeof w2p_ajax_confirm_message != 'undefined') ? w2p_ajax_confirm_message : "Are you sure you want to delete this object?"; + doc.on('click', "input[type='checkbox'].delete", function(){if(this.checked) if(!confirm(confirm_message)) this.checked=false;}); +}; + jQuery(function() { var flash = jQuery('.flash'); flash.hide(); if(flash.html()) flash.slideDown(); web2py_ajax_init(document); + web2py_event_handlers(); }); + function web2py_trap_form(action,target) { jQuery('#'+target+' form').each(function(i){ var form=jQuery(this); @@ -60,6 +65,7 @@ function web2py_trap_form(action,target) { }); }); } + function web2py_trap_link(target) { jQuery('#'+target+' a.w2p_trap').each(function(i){ var link=jQuery(this); @@ -70,11 +76,12 @@ function web2py_trap_link(target) { }); }); } -function web2py_ajax_page(method,action,data,target) { - jQuery.ajax({'type':method,'url':action,'data':data, + +function web2py_ajax_page(method, action, data, target) { + jQuery.ajax({'type':method, 'url':action, 'data':data, 'beforeSend':function(xhr) { - xhr.setRequestHeader('web2py-component-location',document.location); - xhr.setRequestHeader('web2py-component-element',target);}, + xhr.setRequestHeader('web2py-component-location', document.location); + xhr.setRequestHeader('web2py-component-element', target);}, 'complete':function(xhr,text){ var html=xhr.responseText; var content=xhr.getResponseHeader('web2py-component-content'); @@ -94,9 +101,11 @@ function web2py_ajax_page(method,action,data,target) { } }); } + function web2py_component(action,target) { - jQuery(function(){ web2py_ajax_page('get',action,null,target); }); + jQuery(function(){web2py_ajax_page('get',action,null,target);}); } + function web2py_comet(url,onmessage,onopen,onclose) { if ("WebSocket" in window) { var ws = new WebSocket(url); diff --git a/applications/examples/views/default/index.html b/applications/examples/views/default/index.html index e587719f..46783d29 100644 --- a/applications/examples/views/default/index.html +++ b/applications/examples/views/default/index.html @@ -39,7 +39,7 @@ Current version: {{="%s.%s.%s (%s) %s" % request.env.web2py_version}}

diff --git a/applications/examples/views/layout.html b/applications/examples/views/layout.html index bd813d77..0f5cc8d8 100644 --- a/applications/examples/views/layout.html +++ b/applications/examples/views/layout.html @@ -87,7 +87,7 @@
- 2011 BOSSIE AWARD FOR OPEN SOURCE DEVELOPMENT SOFTWARE + InfoWorld's 2012 Technology of the Year Award Winner
diff --git a/applications/welcome/static/js/web2py.js b/applications/welcome/static/js/web2py.js index ec9599fc..64b0f3a1 100644 --- a/applications/welcome/static/js/web2py.js +++ b/applications/welcome/static/js/web2py.js @@ -23,10 +23,6 @@ function ajax(u,s,t) { String.prototype.reverse = function () { return this.split('').reverse().join('');}; function web2py_ajax_fields(target) { - jQuery('input.integer', target).keyup(function(){this.value=this.value.reverse().replace(/[^0-9\-]|\-(?=.)/g,'').reverse();}); - jQuery('input.double,input.decimal', target).keyup(function(){this.value=this.value.reverse().replace(/[^0-9\-\.,]|[\-](?=.)|[\.,](?=[0-9]*[\.,])/g,'').reverse();}); - var confirm_message = (typeof w2p_ajax_confirm_message != 'undefined') ? w2p_ajax_confirm_message : "Are you sure you want to delete this object?"; - jQuery("input[type='checkbox'].delete", target).live('click',function(){ if(this.checked) if(!confirm(confirm_message)) this.checked=false; }); var date_format = (typeof w2p_ajax_date_format != 'undefined') ? w2p_ajax_date_format : "%Y-%m-%d"; var datetime_format = (typeof w2p_ajax_datetime_format != 'undefined') ? w2p_ajax_datetime_format : "%Y-%m-%d %H:%M:%S"; jQuery("input.date",target).each(function() {Calendar.setup({inputField:this, ifFormat:date_format, showsTime:false });}); @@ -38,17 +34,26 @@ function web2py_ajax_fields(target) { function web2py_ajax_init(target) { jQuery('.hidden', target).hide(); jQuery('.error', target).hide().slideDown('slow'); - jQuery('.flash', target).click(function(e) { jQuery(this).fadeOut('slow'); e.preventDefault(); }); - // jQuery('input[type=submit]').click(function(){var t=jQuery(this);t.hide();t.after('')}); web2py_ajax_fields(target); }; +function web2py_event_handlers() { + var doc = jQuery(document) + doc.on('click', '.flash', function(e){jQuery(this).fadeOut('slow'); e.preventDefault();}); + doc.on('keyup', 'input.integer', function(){this.value=this.value.reverse().replace(/[^0-9\-]|\-(?=.)/g,'').reverse();}); + doc.on('keyup', 'input.double, input.decimal', function(){this.value=this.value.reverse().replace(/[^0-9\-\.,]|[\-](?=.)|[\.,](?=[0-9]*[\.,])/g,'').reverse();}); + var confirm_message = (typeof w2p_ajax_confirm_message != 'undefined') ? w2p_ajax_confirm_message : "Are you sure you want to delete this object?"; + doc.on('click', "input[type='checkbox'].delete", function(){if(this.checked) if(!confirm(confirm_message)) this.checked=false;}); +}; + jQuery(function() { var flash = jQuery('.flash'); flash.hide(); if(flash.html()) flash.slideDown(); web2py_ajax_init(document); + web2py_event_handlers(); }); + function web2py_trap_form(action,target) { jQuery('#'+target+' form').each(function(i){ var form=jQuery(this); @@ -60,6 +65,7 @@ function web2py_trap_form(action,target) { }); }); } + function web2py_trap_link(target) { jQuery('#'+target+' a.w2p_trap').each(function(i){ var link=jQuery(this); @@ -70,11 +76,12 @@ function web2py_trap_link(target) { }); }); } -function web2py_ajax_page(method,action,data,target) { - jQuery.ajax({'type':method,'url':action,'data':data, + +function web2py_ajax_page(method, action, data, target) { + jQuery.ajax({'type':method, 'url':action, 'data':data, 'beforeSend':function(xhr) { - xhr.setRequestHeader('web2py-component-location',document.location); - xhr.setRequestHeader('web2py-component-element',target);}, + xhr.setRequestHeader('web2py-component-location', document.location); + xhr.setRequestHeader('web2py-component-element', target);}, 'complete':function(xhr,text){ var html=xhr.responseText; var content=xhr.getResponseHeader('web2py-component-content'); @@ -94,9 +101,11 @@ function web2py_ajax_page(method,action,data,target) { } }); } + function web2py_component(action,target) { - jQuery(function(){ web2py_ajax_page('get',action,null,target); }); + jQuery(function(){web2py_ajax_page('get',action,null,target);}); } + function web2py_comet(url,onmessage,onopen,onclose) { if ("WebSocket" in window) { var ws = new WebSocket(url); diff --git a/gluon/__init__.py b/gluon/__init__.py index d2906318..32ab0473 100644 --- a/gluon/__init__.py +++ b/gluon/__init__.py @@ -20,6 +20,17 @@ from dal import DAL, Field from sqlhtml import SQLFORM, SQLTABLE from compileapp import LOAD +# Dummy code to enable code completion in IDE's. +if 0: + from globals import Request, Response, Session + from cache import Cache + from languages import translator + request = Request() + response = Response() + session = Session() + cache = Cache(request) + T = translator(request) + diff --git a/gluon/dal.py b/gluon/dal.py index 09b9b4a5..cfe46e01 100644 --- a/gluon/dal.py +++ b/gluon/dal.py @@ -7769,7 +7769,7 @@ def Rows_unpickler(data): def Rows_pickler(data): return Rows_unpickler, \ - (cPickle.dumps(data.as_list(storage_to_dict=True, + (cPickle.dumps(data.as_list(storage_to_dict=False, datetime_to_str=False)),) copy_reg.pickle(Rows, Rows_pickler, Rows_unpickler)