Пример #1
0
def SubscriberFollowed(obj,event):
    mp = getToolByName(obj,'portal_membership')
#     import pdb
#     pdb.set_trace()
    userobject = mp.getAuthenticatedMember()
    username = userobject.getId()
    fwqlist = list(userobject.getProperty('myfollowquestion'))
    fwtlist = list(userobject.getProperty('myfollowtopic'))
    fwlist = list(userobject.getProperty('myfollow'))

    
    uuid = IUUID(obj,None)
    if uuid == None:return
    if not (uuid in fwlist):
        fwlist.append(uuid)   
        userobject.setProperties(myfollow=fwlist)
        
    if Iquestion.providedBy(obj) and not(uuid in fwqlist):
        fwqlist.append(uuid)   
        userobject.setProperties(myfollowquestion=fwqlist)        
    if Itopic.providedBy(obj) and not(uuid in fwtlist):
        fwtlist.append(uuid)   
        userobject.setProperties(myfollowtopic=fwtlist)         
        
    evlute = IFollowing(obj)    
    if  evlute.available(username):
        evlute.addFollow(username)
        obj.followernum = evlute.followerNum
        obj.reindexObject() 
Пример #2
0
    def isObjecttype(self, obrain):
        """判断是否为问题对象str{1:话题,2:问题}"""
        ob = obrain.getObject()
        """话题对象"""
        if Itopic.providedBy(ob):
            return 1
        """问题对象"""
        if Iquestion.providedBy(ob):
            return 2

        return 3