<s> """<STR_LIT>""" <EOL> import simplejson <EOL> import pickle <EOL> from google . appengine . ext import db <EOL> class GAEMAUser ( db . Model ) : <EOL> service = db . StringProperty ( required = True ) <EOL> user_data = db . BlobProperty ( required = True ) <EOL> created = db . DateTimeProperty ( auto_now_add = True ) <EOL> updated = db . DateTimeProperty ( auto_now = True ) <EOL> @ classmethod <EOL> def get_or_insert ( cls , key_name , user ) : <EOL> ds_user = cls . get_by_key_name ( key_name ) <EOL> if not ds_user or ds_user . raw_user_data != user : <EOL> ds_user = cls . store_user_data ( key_name , user ) <EOL> return ds_user <EOL> @ classmethod <EOL> def store_user_data ( cls , key_name , user ) : <EOL> """<STR_LIT>""" <EOL> ret = cls ( key_name = key_name , <EOL> user_data = pickle . dumps ( user , pickle . HIGHEST_PROTOCOL ) , <EOL> service = user [ '<STR_LIT>' ] ) <EOL> ret . put ( ) <EOL> return ret <EOL> @ property <EOL> def raw_user_data ( self ) : <EOL> return pickle . loads ( self . user_data ) <EOL> def is_anonymous ( self ) : <EOL> return False <EOL> def is_authenticated ( self ) : <EOL> return True <EOL> @ property <EOL> def is_admin ( self ) : <EOL> from google . appengine . api import users <EOL> return users . is_current_user_admin ( ) <EOL> def __unicode__ ( self ) : <EOL> """<STR_LIT>""" <EOL> user_data = self . raw_user_data <EOL> return user_data [ "<STR_LIT:name>" ] </s>
