diff --git a/VERSION b/VERSION index 10e39c69..b897aec1 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -Version 2.00.0 (2012-08-06 07:25:20) dev +Version 2.00.0 (2012-08-06 08:57:04) dev diff --git a/applications/examples/controllers/cache_examples.py b/applications/examples/controllers/cache_examples.py index 21971da0..930f23c0 100644 --- a/applications/examples/controllers/cache_examples.py +++ b/applications/examples/controllers/cache_examples.py @@ -49,14 +49,3 @@ def cache_controller_and_view(): return response.render(d) -def cache_db_select(): - """cache the database select in ram for 5 seconds""" - - db.users.insert(name='somebody', email='gluon@mdp.cti.depaul.edu') - records = db().select(db.users.ALL, cache=(cache.ram, 5)) - if len(records) > 20: - db(dba.users.id > 0).delete() - return dict(records=records) - - - diff --git a/applications/examples/models/cache_examples/db.py b/applications/examples/models/cache_examples/db.py deleted file mode 100644 index 1a1025c1..00000000 --- a/applications/examples/models/cache_examples/db.py +++ /dev/null @@ -1,69 +0,0 @@ -######################################################################### -## This scaffolding model makes your app work on Google App Engine too -######################################################################### - -if request.controller.endswith('_examples'): response.generic_patterns.append('*') - -from gluon.settings import settings - -# if running on Google App Engine -if settings.web2py_runtime_gae: - from gluon.contrib.gql import * - # connect to Google BigTable - db = DAL('gae') - # and store sessions there - session.connect(request, response, db=db) -else: - # if not, use SQLite or other DB - db = DAL('sqlite://storage.sqlite') - -db.define_table( - 'users', - Field('name'), - Field('email') - ) - -# ONE (users) TO MANY (dogs) - -db.define_table( - 'dogs', - Field('owner_id', db.users), - Field('name'), - Field('type'), - Field('vaccinated', 'boolean', default=False), - Field('picture', 'upload', default=''), - ) - -db.define_table( - 'products', - Field('name'), - Field('description', 'text') - ) - -# MANY (users) TO MANY (purchases) - -db.define_table( - 'purchases', - Field('buyer_id', db.users), - Field('product_id', db.products), - Field('quantity', 'integer') - ) - -# if running on Google App Engine -if settings.web2py_runtime_gae: - # quick hack to skip the join - purchased = None -else: - # use a joined view - purchased = (db.users.id == db.purchases.buyer_id) & (db.products.id - == db.purchases.product_id) - -db.users.name.requires = IS_NOT_EMPTY() -db.users.email.requires = [IS_EMAIL(), IS_NOT_IN_DB(db, 'users.email')] -db.dogs.owner_id.requires = IS_IN_DB(db, 'users.id', 'users.name') -db.dogs.name.requires = IS_NOT_EMPTY() -db.dogs.type.requires = IS_IN_SET(['small', 'medium', 'large']) -db.purchases.buyer_id.requires = IS_IN_DB(db, 'users.id', 'users.name') -db.purchases.product_id.requires = IS_IN_DB(db, 'products.id', - 'products.name') -db.purchases.quantity.requires = IS_INT_IN_RANGE(0, 10) diff --git a/applications/examples/models/default/quotes.py b/applications/examples/models/default/quotes.py deleted file mode 100644 index 79d83658..00000000 --- a/applications/examples/models/default/quotes.py +++ /dev/null @@ -1,12 +0,0 @@ -import random -quotes = [ - ("web2py was the life saver today for me, my blog post: Standalone Usage of web2py's", "caglartoklu", "http://twitter.com/#!/caglartoklu/status/84292131707031553"), - ("Get Things Done - Faster, Better and More Easily with web2py", - "Bruno Rocha", "http://twitter.com/#!/rochacbruno/status/73583156044890112"), - ("Please use www.web2py.com when using MVC , no PHP/SQL stuff please...its 2011 not 1999", "rabblesoft", "http://twitter.com/#!/rabblesoft/status/79189028431343616"), - ('web2py rules! as a sysadmin I like the no installation and no configuration approach a lot)', "kjogut", "http://twitter.com/#!/jkogut/status/61414554273447936"), - ("web2py it is. Compatible with everything under the sun and great interfaces to googleappengine", "comamitc","http://twitter.com/#!/comamitc/status/51744719071477760"), - ("If you are still learning python, web2py is best tool by far", "pbreit", "http://twitter.com/#!/pbreit/status/48260905775017984") - ] -random.shuffle(quotes) - diff --git a/applications/examples/views/default/examples.html b/applications/examples/views/default/examples.html index 2f6fd325..29191d53 100644 --- a/applications/examples/views/default/examples.html +++ b/applications/examples/views/default/examples.html @@ -593,7 +593,6 @@ def cache_db_select(): return dict(records=records) """.strip(),language='web2py',link=URL('global','vars'),_class='boxCode')}}

The results of a select are complex unpickleable objects that cannot be cached using the previous method, but the select command takes an argument cache=(cache_model,time_expire) and will cache the result of the query accordingly. Notice that the key is not necessary since key is generated based on the database name and the select string. -
Try it here: cache_db_select

Ajax Examples

diff --git a/applications/examples/views/default/index.html b/applications/examples/views/default/index.html index 0d37338e..4548ad8a 100644 --- a/applications/examples/views/default/index.html +++ b/applications/examples/views/default/index.html @@ -1,5 +1,18 @@ {{right_sidebar_enabled=True}} {{extend 'layout.html'}} +{{ +import random +quotes = [ + ("web2py was the life saver today for me, my blog post: Standalone Usage of web2py's", "caglartoklu", "http://twitter.com/#!/caglartoklu/status/84292131707031553"), + ("Get Things Done - Faster, Better and More Easily with web2py", + "Bruno Rocha", "http://twitter.com/#!/rochacbruno/status/73583156044890112"), + ("Please use www.web2py.com when using MVC , no PHP/SQL stuff please...its 2011 not 1999", "rabblesoft", "http://twitter.com/#!/rabblesoft/status/79189028431343616"), + ('web2py rules! as a sysadmin I like the no installation and no configuration approach a lot)', "kjogut", "http://twitter.com/#!/jkogut/status/61414554273447936"), + ("web2py it is. Compatible with everything under the sun and great interfaces to googleappengine", "comamitc","http://twitter.com/#!/comamitc/status/51744719071477760"), + ("If you are still learning python, web2py is best tool by far", "pbreit", "http://twitter.com/#!/pbreit/status/48260905775017984") + ] +random.shuffle(quotes) +}}