コード例 #1
0
def getGroup(groupid):
    group=memcache.get('groupbyid'+str(groupid))
    if group:
        return group
    else:
        group=Group.get_by_id(groupid)
        memcache.set('groupbyid'+str(groupid),group,3600)
        return group
コード例 #2
0
ファイル: rssinterface.py プロジェクト: wangjian2254/moguim
def memacheGroup(groupid):
    group=memcache.get('groupbyid'+str(groupid))
    if not group:
        if '0000'==groupid:
            group=Group()
            group.name=u'大厅'
            return group
        groupid=int(groupid)
        if groupid:
            group=Group.get_by_id(int(groupid))
            memcache.set('groupbyid'+str(groupid),group,36000)
        else:
            return None
    return group
コード例 #3
0
    def get(self):
        groupid=self.request.get('groupid')
        tagmap={}
        for tag in Tag.all():
            tagmap[str(tag.key().id())]=tag.name

        username=get_current_user(self)
        user=getorAddUser(username)
        if groupid:
            groupid=int(groupid)
#            group=Group.get_by_id(groupid)
            group=getGroup(groupid)
            if group.author==username:
                group.delete()
                nlist=[]
                rnlist=[]
                for n in Note.all().filter('group =',groupid):
                    nlist.append(n)
                    rnlist.append('r'+str(n.key().id()))
                db.delete(Replay.get_by_key_name(rnlist))
                db.delete(nlist)
                if groupid in user.createGroup:
                    user.createGroup.remove(groupid)
                    user.put()
                if groupid in user.createGroupAdd:
                    user.createGroupAdd.remove(groupid)
                    user.put()


        groupidlist=user.createGroup+user.createGroupAdd
        list=Group.get_by_id(groupidlist)
#        list=Group.all().filter('author =',username)
        listgroup=[]
        ischange=False
        for i,group in enumerate(list):
            if not group:
                if groupidlist[i] in user.createGroup:
                    user.createGroup.remove(groupidlist[i])
                    ischange=True
                if groupidlist[i] in user.createGroupAdd:
                    user.createGroupAdd.remove(groupidlist[i])
                    ischange=True
            else:
                group.tagname=tagmap.get(str(group.tag),'')
                listgroup.append(group)
        if ischange:
            user.put()
        self.render('templates/removegroupList.html',{'list':listgroup})
コード例 #4
0
 def get(self):
     msgid=self.request.get('msg')
     msg=None
     if msgid:
         msg=memcache.get(msgid)
     newrsslist=getNewRssList()
     if newrsslist==None:
         newrsslist=NewRSSList(key_name='newrsslist')
         newrsslist.put()
         memcache.set('newrsslist',newrsslist,360000)
     groupids=newrsslist.groupids
     groupids.reverse()
     if groupids:
         grouplist=Group.get_by_id(groupids)
     else:
         grouplist=[]
     self.render('templates/newrss.html',{'list':grouplist,'msg':msg})
コード例 #5
0
 def post(self):
     tagmap={}
     for tag in Tag.all():
         tagmap[str(tag.key().id())]=tag.name
     username=get_current_user(self)
     if '000'==username:
         type=self.request.get('type','')
         value=self.request.get('value',0)
         list=[]
         if type=='username':
             list=Group.all().filter('author =',str(value))
         if type=='groupid':
             list=Group.get_by_id([int(value)])
     else:
         list=Group.all().filter('author =',username)
     listgroup=[]
     for group in list:
         group.tagname=tagmap.get(str(group.tag),'')
         listgroup.append(group)
     self.render('templates/groupList.html',{'list':listgroup,'tagmap':tagmap,'isadmin':('000'==username and [True] or [False])[0]})
コード例 #6
0
    def post(self):
        groupid=self.request.get('groupid')
        if groupid:
            groupid=int(groupid)
            newrsslist=getNewRssList()

            if not  newrsslist or not Group.get_by_id(groupid) :
                msg=u'添加失败,群不存在。'
            elif newrsslist and groupid not in newrsslist.groupids:
                newrsslist.groupids.append(groupid)
                newrsslist.put()
                memcache.set('newrsslist',newrsslist,360000)
                msg=u'添加成功。'
            else:
                msg=u'添加失败,已经存在。'
        else:
            msg=u'添加失败,没有群号'

        msgid=str(uuid.uuid4())
        memcache.set(msgid,msg,3600)
        self.redirect('/NewRSSListM?msg='+msgid)