I have this extremely efficient object oriented hierarchical 
construct (working parallel) under GAE:

class *my_object_Root*(BaseModel):
    *total_counter *= db.IntegerProperty()

class *my_object*(db.Model):
    *name *= db.StringProperty()

    #That's it ! Super fast !
    @classmethod
    def *get_profile*(self, name):
        if not name:
            return None
        root = my_object_Root.get_profile()
        #cache
        self._cache = get_cache("memcached://")
        skey = name
        key_cache = 'my_object' + skey + str(root.key())
        profile = self._cache.get(key_cache)
        #cache        
        if not profile:
            key = db.Key.from_path('my_object',
                                   skey,
                                   parent=root.key())
            profile = db.get(key)
            # not found - create
            if not profile:
                root = my_object_Root.get_profile_del_cache()
                profile = my_object(key_name=skey,
                                       parent=root.key())
                profile.put()
                return profile
            #cache
            self._cache.set(key_cache, profile, timeout=CACHE_TIMEOUT)
            #cache
        return profile

*Usage:*
my_object_name = "Test Name"
my_name = models.my_object.get_profile(my_object_name)
name = my_name.name 

*total_counter* is in the root: *my_object_Root* of the object
*my_object. *We can have many children of *my_object *under
*my_object_Root *and* *additional code is updating *total_counter* 
when I am adding another *my_object. *That way one very difficult
to implement and slow operation - counting is done very efficiently
on the fly and it works very quick.

This and other construct are impossible to achieve the same efficiency
under SQL so the only way I see to achieve this under web2py is web2py 
abstraction layer to have a way transparently to use GAE.

Are there currently a way to achieve this?

Thanks in advance,




Reply via email to