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()
def isObjecttype(self, obrain): """判断是否为问题对象str{1:话题,2:问题}""" ob = obrain.getObject() """话题对象""" if Itopic.providedBy(ob): return 1 """问题对象""" if Iquestion.providedBy(ob): return 2 return 3
def AddTopicPortlet(obj, event): """ this will add the relatedinformation portlet to topic automatically.""" parent = aq_parent(obj) if Itopic.providedBy(parent): return # A portlet manager is akin to a column column = getUtility(IPortletManager, name=PROMOTIONS_PORTLET_COLUMN) # We multi-adapt the object and the column to an assignment mapping, # which acts like a dict where we can put portlet assignments manager = getMultiAdapter((obj, column,), IPortletAssignmentMapping) # We then create the assignment and put it in the assignment manager, # using the default name-chooser to pick a suitable name for us. assignment = relatedinformation.Assignment() chooser = INameChooser(manager) manager[chooser.chooseName(None, assignment)] = assignment