It is only possible to use memcache or datastore from google on GAE.
Brent Pedersen implemented a memcache store class in his code.
Here is the implementation for google store.  The only caveat in
original session file is the cleanup time is too long, deletion on GAE
store need to be executed on a per recorded basis.

class WebpySession(db.Model):
    data = db.BlobProperty()
    atime = db.DateTimeProperty(auto_now=True)

class GoogleStore(Store):
    """Google Datastore"""
    def __init__(self, prefix="p"):
        self.prefix=prefix

    def __contains__(self, key):
        return WebpySession.get_by_key_name(self.prefix+key) is not
None

    def __getitem__(self, key):
        try:
            return
pickle.loads(WebpySession.get_by_key_name(self.prefix+key).data)
        except AttributeError:
            raise KeyError, key

    def __setitem__(self, key, value):
        r = WebpySession.get_or_insert(self.prefix+key)
        r.data = pickle.dumps(value)
        r.put()

    def __delitem__(self, key):
        try:
            WebpySession.get_by_key_name(self.prefix+key).delete()
        except AttributeError:
            pass
    def cleanup(self, timeout):
        db.delete(WebpySession.all().filter('atime <',
datetime.datetime.now()-
datetime.timedelta(seconds=timeout)).fetch(CLEANUP_BATCH_SIZE))


On Oct 24, 5:57 pm, "Anand Chitipothu" <[EMAIL PROTECTED]> wrote:
> On Sat, Oct 25, 2008 at 3:20 AM, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
> > OK, i'M ALMOST THERE!
> > But...
>
> >    session = web.session.Session(app)
> >    TypeError: __init__() takes at least 3 arguments (2 given)
> >    INFO     2008-10-24 22:24:10,558 dev_appserver.py] "GET / HTTP/
> > 1.1" 500 -
>
> I am getting a different error.
>
>   File "/Users/anand/work/webpy/gae/helloworld/web/session.py", line
> 184, in __init__
>     os.mkdir(root)
> AttributeError: 'module' object has no attribute 'mkdir'
>
> I think it is because app engine doesn't allow you to create
> directories or write files.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web.py" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/webpy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to