Trying to make the web2py examples run out of the box on google apps
engine (sdk). It now runs almost all examples, only the purchase part
of the database not yet, anyone a suggestion for this?

The fixing might be a bit quick&dirty, but I was after the results.


Index: applications/examples/controllers/database_examples.py
===================================================================
--- applications/examples/controllers/database_examples.py      (revision
953)
+++ applications/examples/controllers/database_examples.py      (working
copy)
@@ -100,9 +100,13 @@

     # ## now get a list of all purchases

-    records = db(purchased).select(db.users.name,
-                                   db.purchases.quantity,
-                                   db.products.name)
+    # quick fix to make it runnable on gae
+    if purchased:
+        records = db(purchased).select(db.users.name,
+                                       db.purchases.quantity,
+                                       db.products.name)
+    else:
+        records = db().select(db.users.ALL))
     return dict(form=form, records=SQLTABLE(records), vars=form.vars,
                 vars2=request.vars)

Index: applications/examples/models/db.py
===================================================================
--- applications/examples/models/db.py  (revision 953)
+++ applications/examples/models/db.py  (working copy)
@@ -33,8 +33,12 @@
                 SQLField('product_id', db.products), SQLField
('quantity'
                 , 'integer'))

-purchased = (db.users.id == db.purchases.buyer_id) & (db.products.id
-         == db.purchases.product_id)
+from gluon.settings import settings
+if not settings.web2py_runtime_gae:
+    purchased = (db.users.id == db.purchases.buyer_id) &
(db.products.id
+                 == db.purchases.product_id)
+else:
+    purchased = None

 db.users.name.requires = IS_NOT_EMPTY()
 db.users.email.requires = [IS_EMAIL(), IS_NOT_IN_DB(db,
'users.email')]
Index: gluon/cache.py
===================================================================
--- gluon/cache.py      (revision 953)
+++ gluon/cache.py      (working copy)
@@ -160,11 +160,21 @@
 class Cache(object):

     def __init__(self, request):
-        self.ram = CacheInRam(request)
-        try:
-            self.disk = CacheOnDisk(request)
-        except IOError:
-            logging.warning('no cache.disk')
+
+        from gluon.settings import settings
+        if settings.web2py_runtime_gae:
+            from gluon.contrib.gae_memcache import MemcacheClient
+            self.ram=self.disk=MemcacheClient(request)
+        else:
+
+
+            self.ram = CacheInRam(request)
+            try:
+                self.disk = CacheOnDisk(request)
+            except IOError:
+                logging.warning('no cache.disk (IOError)')
+            except AttributeError:
+                logging.warning('no cache.disk (AttributeError)')

     def __call__(
         self,
Index: gluon/compileapp.py
===================================================================
--- gluon/compileapp.py (revision 953)
+++ gluon/compileapp.py (working copy)
@@ -37,7 +37,8 @@
     logging.warning('unable to import py_compile')
 from rewrite import error_message_custom

-is_gae = settings.web2py_runtime in
['gae:development','gae:production']
+#is_gae = settings.web2py_runtime in
['gae:development','gae:production']
+is_gae = settings.web2py_runtime_gae

 TEST_CODE = \
     r"""
Index: gaehandler.py
===================================================================
--- gaehandler.py       (revision 953)
+++ gaehandler.py       (working copy)
@@ -15,10 +15,15 @@

 from gluon.settings import settings

+
+
+
 if os.environ.get('SERVER_SOFTWARE','').startswith('Devel'):
-    (settings.web2py_runtime, debug) = ('gae:development', True)
+    (settings.web2py_runtime, settings.web2py_runtime_gae, debug) = \
+        ('gae:development', True, True)
 else:
-    (settings.web2py_runtime, debug) = ('gae:production', False)
+    (settings.web2py_runtime, settings.web2py_runtime_gae, debug) = \
+        ('gae:production', True, False)

 import gluon.main


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to