def post(self): user = users.get_current_user() wordlist = WordList(owner=user) wordlist.put() self.response.headers['Content-Type'] = 'application/json' # FIXME: should use JSON printer self.response.out.write('{"ListId": "%s"}' % wordlist.key())
def post(self): user = users.get_current_user() wordlist = WordList(owner=user) wordlist.put() listid = wordlist.key() json = '{"ListId": "%s"}' % listid self.response.headers["Content-Type"] = "application/json" self.response.out.write(json)
def get(self): i = 0 for wordlist in wordlists: wl = WordList(name="wordlist%02d" % i, owner=users.get_current_user()) wl.put() for spelling, meaning in wordlist: w = Word(spelling=spelling, meaning=meaning) w.put() m = WordMember(wordlist=wl, word=w) m.put() i += 1 self.redirect('/words')
def get(self): wordlists = WordList.all().filter('owner =', users.get_current_user()) wordlist_key = self.request.get('wordlist_key') if wordlist_key: wordlist = WordList.get(wordlist_key) else: wordlist = wordlists and wordlists.get() # FIXME: an exception will be thrown if the user has no wordlists template_values = {'words': wordlist.words, 'wordlists': wordlists, 'wordlist_name': wordlist.name} path = join(dirname(dirname(dirname(__file__))), 'template', 'words.html') self.response.out.write(template.render(path,template_values))
def getWordList(user,id): query = WordList.all() query = query.filter('key =', id) query = query.filter('user =', user) return query.get()