Esempio n. 1
0
 def post(self):
         self.response.headers['Content-Type'] = 'text/html'
         user = users.get_current_user()
         newword = self.request.get('addword')
         lexico_order=''.join(sorted(set(newword)))
         userid=users.get_current_user().email()
         userid = hashlib.sha1('%s' % (userid)).hexdigest()
         key = ndb.Key('MyList', lexico_order+userid)
         my_list = key.get()
         if my_list==None:
             my_list=MyList(id=lexico_order+userid)
             my_list.put()
         key = ndb.Key('MyList', lexico_order+userid)
         my_list = key.get()
         action=self.request.get('button')
         if action == 'Submit':
             string = self.request.get('addword')
             if string == None or string == '':
                 self.redirect('/')
                 return
             my_list.list_of_words.append(newword)
             my_list.lexicographical=lexico_order
             my_list.word_count=len(my_list.list_of_words)
             my_list.letter_count=len(my_list.lexicographical)
             my_list.user_id=userid
         my_list.put()
         self.redirect('/add')
Esempio n. 2
0
 def post(self):
     self.response.headers['Content-Type'] = 'text/html'
     userid = users.get_current_user().email()
     userid = hashlib.sha1('%s' % (userid)).hexdigest()
     textfile = self.request.get("myFile")
     textfile = textfile.split()
     for x in textfile:
         line=''.join(sorted(set(x)))
         key = ndb.Key('MyList', line+userid)
         my_list = key.get()
         if my_list==None:
             my_list=MyList(id=line+userid)
             my_list.put()
         key = ndb.Key('MyList', line+userid)
         my_list = key.get()
         my_list.list_of_words.append(x)
         my_list.lexicographical=line
         my_list.word_count=len(my_list.list_of_words)
         my_list.letter_count=len(my_list.lexicographical)
         my_list.user_id=userid
         my_list.put()
     self.redirect('/')