Tuesday, February 10, 2015

Setting cookie 'expires' for Google App Engine webapp2_extras.sessions

I like Google App Engine for all the good reasons but it took me some time to
set 'expires' time for session cookies when using webapp2_extras.sessions .



webapp2_extras.sessions only provide control alter max_age of cookie based session and I wanted to control 'expires' time based 'remember me' check box.

Following hack did the trick for me.

class CustomerLogin(webapp2.RequestHandler):
    def dispatch(self):
        # Get a session store for this request.
       
        if bool(cgi.escape(self.request.get('remember'))):
            self.request.app.config['webapp2_extras.sessions']['cookie_args']['expires'] = (datetime.datetime.utcnow()  + datetime.timedelta(minutes=30))
            pass
        else:
            self.request.app.config['webapp2_extras.sessions']['cookie_args']['expires'] = None
               
        self.session_store = sessions.get_store(request=self.request)

        try:
            # Dispatch the request.
            webapp2.RequestHandler.dispatch(self)
        finally:
            # Save all sessions.
            self.session_store.save_sessions(self.response)

Tuesday, October 26, 2010

Installing Python 2.5 for Google App Engine on Ubuntu

This was useful only for OLD App Engine 
Current GAE has moved to Python 2.7

Installing Python2.5 for Google App Engine on Ubuntu took me some time on my new 64-bit Ubuntu 10.04. So for others this is a small How-To ..

Ubuntu 10.04 official repository doesn't has package for Python2.5 and GAE needs it.

I thought of building it from src but ran into weird errors and was lazy enough to look for using some-one else's work.

Some Googel'ing pointed me to a gentleman's efforts who has compiled it for others. (This worked on my earlier 32-bit Lucid installation but not on 64-bit)


My Quick FIX

1) Add following line on top of your repository list (/etc/apt/sources.list)
deb http://ftp.debian.org/debian/ lenny main contrib non-free


2) $ sudo apt-get update

3) $
sudo apt-get install python2.5

4) $ python2.5
 

... Bingo


To use only ubuntu packages in future undo changes done in sources.list ..


Update:
On Ubuntu 10.10 just compiled it from the source code.... 

Thursday, September 25, 2008

hi,

This is Aditya Tiwari.
I like bits and bytes.
I have worked on wast variety of things like,
Op-amps to FPGAs,
Assembly language to Python.
8bit uC to 8 core SOCs.
Presently I am working with Freescale Semiconductors as design engineer.
I write models of network SOCs.

I live in India.