Example #1
0
 def PumpActivityState(self, state_pickle):
   state_pickle = str(state_pickle)
   #logging.info('I JUST RECEIVED PICKLE TYPE: %r - %s (PumpActivityState)', type(state_pickle), state_pickle)
   if len(state_pickle) == 0:
     logging.debug('JokeMachineSession.ReceiveActivityState() -> empty state_pickle - creating empty state')
     activity_state = JokeMachineState().test_data()
   else:
     logging.debug('JokeMachineSession.ReceiveActivityState() -> Unpickling state from remote')
     activity_state = JokeMachineState.loads(state_pickle)
   Globals.set_activity_state(activity_state) 
   
   # refresh activity ui
   Globals.JokeMachineActivity.refresh()
   logging.debug('Finished receiving state')    
  def read_file(self, file_path):
    '''Callback to resume activity state from Journal'''
    logging.debug('Reading file from datastore via Journal: %s' % file_path)
    f = open(file_path, 'r')
    pickle = f.read()
    if len(pickle) == 0:
      logging.debug('Activity.read_file() -> Journal has empty pickle - creating empty state')
      activity_state = JokeMachineState().test_data()
    else:
      logging.debug('Unpickling state from Journal')
      activity_state = JokeMachineState.loads(pickle)
    f.close()

    # set Globals.ActivityState
    Globals.set_activity_state(activity_state) 
Example #3
0
    def PumpActivityState(self, state_pickle):
        state_pickle = str(state_pickle)
        #logging.info('I JUST RECEIVED PICKLE TYPE: %r - %s (PumpActivityState)', type(state_pickle), state_pickle)
        if len(state_pickle) == 0:
            logging.debug(
                'JokeMachineSession.ReceiveActivityState() -> empty state_pickle - creating empty state'
            )
            activity_state = JokeMachineState().test_data()
        else:
            logging.debug(
                'JokeMachineSession.ReceiveActivityState() -> Unpickling state from remote'
            )
            activity_state = JokeMachineState.loads(state_pickle)
        Globals.set_activity_state(activity_state)

        # refresh activity ui
        Globals.JokeMachineActivity.refresh()
        logging.debug('Finished receiving state')
Example #4
0
    def read_file(self, file_path):
        '''Callback to resume activity state from Journal'''
        logging.debug('Reading file from datastore via Journal: %s' %
                      file_path)
        f = open(file_path, 'r')
        pickle = f.read()
        if len(pickle) == 0:
            logging.debug(
                'Activity.read_file() -> Journal has empty pickle - creating empty state'
            )
            activity_state = JokeMachineState().test_data()
        else:
            logging.debug('Unpickling state from Journal')
            activity_state = JokeMachineState.loads(pickle)
        f.close()

        # set Globals.ActivityState
        Globals.set_activity_state(activity_state)
Example #5
0
    for name, prop in obj.__properties__:
        value = prop.fget(obj)
        print indent + name, "=", value  # , ' "' + prop.__doc__ + '"'
        if value.__class__ is list:
            for item in value:
                dump(item, indent + "  ")

    print indent + "is_dirty =", obj.__dirty__


state = JokeMachineState()
state = state.test_data()
dump(state)
print "\n========================================================================\n"
pickle = state.dumps()
j = JokeMachineState.loads(pickle)
jokebook = j.jokebooks[0]
jokebook.owner = "new owner"
dump(j)


sys.exit()


joke = Joke()

print "Joke.id.doc: ", Joke.id.__doc__
print "Joke.joke_text.doc: ", Joke.text.__doc__
print

print "joke.id default should be 0 = ", joke.id
Example #6
0
    for name, prop in obj.__properties__:
        value = prop.fget(obj)
        print indent + name, '=', value  #, ' "' + prop.__doc__ + '"'
        if value.__class__ is list:
            for item in value:
                dump(item, indent + '  ')

    print indent + 'is_dirty =', obj.__dirty__


state = JokeMachineState()
state = state.test_data()
dump(state)
print "\n========================================================================\n"
pickle = state.dumps()
j = JokeMachineState.loads(pickle)
jokebook = j.jokebooks[0]
jokebook.owner = 'new owner'
dump(j)

sys.exit()

joke = Joke()

print 'Joke.id.doc: ', Joke.id.__doc__
print 'Joke.joke_text.doc: ', Joke.text.__doc__
print

print 'joke.id default should be 0 = ', joke.id
print 'joke is dirty = ', joke.__dirty__
print