I am using GAE models directly:


if not request.env.web2py_runtime_gae:     
    ## if NOT running on Google App Engine use SQLite or other DB
    db = DAL('sqlite://storage.sqlite') 
    auth = Auth(db, hmac_key=Auth.get_or_create_key()) 
    crud, service, plugins = Crud(db), Service(), PluginManager()
else:
    ## connect to Google BigTable (optional 'google:datastore://namespace')
    db = DAL('google:datastore')
    auth = Auth(db, hmac_key=Auth.get_or_create_key()) 
    crud, service, plugins = Crud(db), Service(), PluginManager()
 
    from gluon.contrib.gae_memcache import MemcacheClient
    from gluon.contrib.memdb import MEMDB


        cache.memcache = MemcacheClient(request)

    class MyRoot(google_db.Model):
       total_users = google_db.IntegerProperty(required=True, default=0)

               def get_profile(self):

       #key
          key = google_db.Key.from_path('MyRoot', 'root')
       #entity
          e = google_db.get(key)


       ######

       #put in cache

       ######     

       #key_cache = 'MyRoot' + 'root'

       #t = cache.memcache(key_cache,lambda:e,CACHE_TIMEOUT)

       ######

       #put in cache

       ######     


       e = MyRoot.get_profile()

       if e:

         e.total_users = 2

         e.put()


This code is working and I can see the data object on the Google AppEngine GAE 
server in DataView.


I have the following issues:


1) When I want to store the entity in a cache,

e.g. when I un-comment the following:


     ######

     #put in cache

     ######     

     key_cache = 'MyRoot' + 'root'

     *t = cache.memcache(key_cache,lambda:e,CACHE_TIMEOUT)*

     ######

     #put in cache

     ######     


PicklingError: Can't pickle <class 'MyRoot'>: it's not found as 
__builtin__.MyRoot


2) This code is working only when uploaded to the AppEngine GAE server. How to 

make it work locally in order to test it locally first?


Thank in advance,


Regards,

--Constantine





Reply via email to