Beispiel #1
0
 def __do_clicked_make(self, button):
     # create a new jokebook
     jokebook = Jokebook()
     jokebook.id = Globals.JokeMachineState.next_jokebook_id
     logging.info('Created new jokebook with id: %d' % jokebook.id)
     jokebook.owner = Globals.nickname
     Globals.JokeMachineState.jokebooks.append(jokebook)
     Globals.JokeMachineActivity.set_page(pages.edit.Edit, jokebook)
Beispiel #2
0
 def __do_clicked_make(self, button):
   # create a new jokebook
   jokebook = Jokebook()
   jokebook.id = Globals.JokeMachineState.next_jokebook_id
   logging.info('Created new jokebook with id: %d' % jokebook.id)
   jokebook.owner = Globals.nickname
   Globals.JokeMachineState.jokebooks.append(jokebook)
   Globals.JokeMachineActivity.set_page(pages.edit.Edit, jokebook)
Beispiel #3
0
 def test_data(self):
   self.id = 1
   # add some jokebooks with jokes
   num_jokebooks = 0
   num_jokes = 2
   num_submissions = 2
   for jokebook_id in range(1, num_jokebooks + 1):
     jokebook = Jokebook()
     jokebook.id = jokebook_id
     jokebook.owner = 'hummingbird'
     jokebook.title = 'Jokebook ' + str(jokebook.id)
     #jokebook.image = 'images/smile-big.png'
     for joke_id in range(1, num_jokes + 1):
       joke = Joke().test_data()
       joke.id = joke_id
       jokebook.jokes.append(joke)
     for joke_id in range(1, num_submissions + 1):
       joke = Joke().test_data()
       joke.id = joke_id
       jokebook.submissions.append(joke)
     self.jokebooks.append(jokebook)
   return self
 def test_data(self):
     self.id = 1
     # add some jokebooks with jokes
     num_jokebooks = 0
     num_jokes = 2
     num_submissions = 2
     for jokebook_id in range(1, num_jokebooks + 1):
         jokebook = Jokebook()
         jokebook.id = jokebook_id
         jokebook.owner = 'hummingbird'
         jokebook.title = 'Jokebook ' + str(jokebook.id)
         #jokebook.image = 'images/smile-big.png'
         for joke_id in range(1, num_jokes + 1):
             joke = Joke().test_data()
             joke.id = joke_id
             jokebook.jokes.append(joke)
         for joke_id in range(1, num_submissions + 1):
             joke = Joke().test_data()
             joke.id = joke_id
             jokebook.submissions.append(joke)
         self.jokebooks.append(jokebook)
     return self
Beispiel #5
0
# ##############################################################################
# test Pickling
#
# jokebook.__dirty__ = False
# jokebook.jokes[0].__dirty__ = False

p = cPickle.dumps(jokebook)
# print p
# o = cPickle.loads(p)

# dump(o)
# dump(o.jokes[0])

print "Persisting..."
print
jokebook.id = 0
dump(jokebook)
print
pickle = jokebook.dumps()
j = Jokebook.loads(pickle)
dump(j)

# print j.jokes.__class__

# print joke
# print joke.__dirty__
# print joke.dirty
# print joke.pdirty


# json
Beispiel #6
0
# ##############################################################################
# test Pickling
#
#jokebook.__dirty__ = False
#jokebook.jokes[0].__dirty__ = False

p = cPickle.dumps(jokebook)
#print p
#o = cPickle.loads(p)

#dump(o)
#dump(o.jokes[0])

print 'Persisting...'
print
jokebook.id = 0
dump(jokebook)
print
pickle = jokebook.dumps()
j = Jokebook.loads(pickle)
dump(j)

#print j.jokes.__class__

#print joke
#print joke.__dirty__
#print joke.dirty
#print joke.pdirty

# json
#p = json.write(j.__dict__)