示例#1
0
 def get(self):
     count = 15
     p = self.request.get('p',1)
     values = myvalues(self.request)
     xmppemail = '*****@*****.**'
     sender = db.IM("xmpp", xmppemail)
     dictkey = xmppemail + '$dict'
     data = memcache.get(dictkey)
     if not data:
         query = MBook.all()
         query.filter('im =', sender).order('-date')
         data = []
         for item in query:
             data.append(dict(
                 key = item.key(),
                 word = item.word,
                 pron = item.pron,
                 define = item.define,
                 rating = item.rating,
                 date = item.date,
             ))
         memcache.set(dictkey, data, 86400)
     values['data'] = pagi(data, count, p)
     tp = os.path.join(DIR, 'admindict.html')
     self.response.out.write(template.render(tp,values))
示例#2
0
 def get(self):
     values = myvalues(self.request)
     xmppemail = values['user'].email().lower()
     sender = db.IM("xmpp", xmppemail)
     query = MBook.all()
     query.filter('im =', sender).order('-date')
     values['data'] = query
     #self.response.headers['Content-Type'] = 'application/atom+xml'
     self.response.headers['Content-Type'] = 'binary/octet-stream'
     tp = os.path.join(DIR, 'mardict.xml')
     self.response.out.write(template.render(tp,values))
示例#3
0
 def post(self):
     values = myvalues(self.request)
     xmppemail = values['user'].email().lower()
     sender = db.IM("xmpp", xmppemail)
     marfile = self.request.get('marfile')
     mar = MarXML(marfile)
     content = mar.parse_data()
     for m in content:
         mdb = MBook.add_record(sender,m['word'], m['define'], m['pron'])
         mdb.date = m['date']
         mdb.put()
     #self.response.out.write(content)
     self.redirect('/user/')
示例#4
0
    def get(self):
        count = 15
        p = self.request.get('p',1)
        values = myvalues(self.request)
        xmppemail = values['user'].email().lower()
        sender = db.IM("xmpp", xmppemail)
        dictkey = xmppemail + '$dict'

        action = self.request.get('action')
        key = self.request.get('key')
        if key and 'delete' == action:
            memcache.delete(dictkey)
            m = db.get(key)
            if m and m.im == sender:
                db.delete(m)
            self.redirect('/user/')
        if 'refresh' == action:
            memcache.delete(dictkey)
            self.redirect('/user/')
        data = memcache.get(dictkey)
        if not data:
            query = MBook.all()
            query.filter('im =', sender).order('-date')
            data = []
            for item in query:
                data.append(dict(
                    key = item.key(),
                    word = item.word,
                    pron = item.pron,
                    define = item.define,
                    rating = item.rating,
                    date = item.date,
                ))
            memcache.set(dictkey, data, 86400)
        values['data'] = pagi(data, count, p)
        tp = os.path.join(DIR, 'user.html')
        self.response.out.write(template.render(tp,values))