Changeset 1215 for trunk/MemberFolder.py


Ignore:
Timestamp:
12/12/06 15:38:12 (13 years ago)
Author:
jukka
Message:

Fixed #1026. Refactored user resources to not generate new topics for every user and use general portfolio-topic. Unauthenticated users tried to create them when one didn't exist in viewed memberfolder. In general I have a gutfeeling that having many so topics reduces their efficiency, but I am open to arguments, it's only feeling.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/MemberFolder.py

    r1213 r1215  
    317317        # the collections and resources folders. 
    318318 
    319     def createResourcesTopic(self): 
    320         # assumes that topic 'resources' doesn't exist 
    321         self.invokeFactory('Topic', id='resources') 
    322         topic=self.resources 
    323         criterion = topic.addCriterion('Type', 'ATPortalTypeCriterion' ) 
    324         criterion.setValue(CREATED_RESOURCES) 
    325         criterion = topic.addCriterion('review_state','ATSelectionCriterion') 
    326         criterion.setValue(('public','draft'))     
    327         criterion = topic.addCriterion('Creator', 'ATSimpleStringCriterion') 
    328         criterion.setValue(self.getId()) 
    329319 
    330320    def getMemberId(self): 
     
    335325        """ return the member, useful for collections, topics etc. subobjects """ 
    336326        return self 
    337  
    338     def createStoriesTopic(self): 
    339         # assumes that topic 'stories' doesn't exist 
    340         self.invokeFactory('Topic', id='stories') 
    341         topic=self.stories 
    342         criterion = topic.addCriterion('Type', 'ATPortalTypeCriterion' ) 
    343         criterion.setValue('Story') 
    344         criterion = topic.addCriterion('review_state','ATSelectionCriterion') 
    345         criterion.setValue(('public','draft')) 
    346         criterion = topic.addCriterion('Creator', 'ATSimpleStringCriterion') 
    347         criterion.setValue(self.getId()) 
    348327 
    349328    def getCollectionsFolder(self): 
     
    509488 
    510489    def getResources(self, n=False, REQUEST=None, filter=None): 
    511         """ Search for content-like created by member. 
    512         The funny REQUEST thingy is because the link to the resources topic 
    513         can't be made directly, since it might not exist. It's created here 
    514         if necessary.""" 
    515         if not hasattr(self.aq_base, 'resources'): 
    516             if n == True: 
    517                 return 0 
    518             self.createResourcesTopic() 
    519         if n==True: 
    520             #if not hasattr(self.aq_base, 'resources_n'): 
    521             if filter is None: 
    522                 results=self.resources.queryCatalog() 
    523             else: 
    524                 results=self.resources.queryCatalog(meta_type=filter) 
    525             #self.resources_n=len(results) 
    526             return len(results) 
    527         else: 
    528            return REQUEST.RESPONSE.redirect(self.resources.absolute_url()) 
     490        """ Get resources from subject of this memberfolder by using general portfolio-topic """ 
     491        if filter is None: 
     492            results=self.portfolio.queryCatalog(Creator=getMemberFolder().getId())  
     493        else: 
     494            results=self.portfolio.queryCatalog(meta_type=filter, Creator=self.getMemberFolder().getId())  
     495        return len(results) 
    529496 
    530497    def getSamples(self): 
    531498        """ get n number of samples """ 
    532         if not hasattr(self.aq_base, 'resources'): 
    533             self.createResourcesTopic() 
    534         q = {'review_state':'public', 'meta_type': self.getFeaturedTypes(), 'getHasCoverImage':True} 
    535         all = self.resources.queryCatalog(q) 
     499        q = {'review_state':'public', 'meta_type': self.getFeaturedTypes(), 'getHasCoverImage':True, 'Creator': self.getMemberFolder().getId()} 
     500        all = self.portfolio.queryCatalog(q) 
    536501        import random 
    537502        n = min(3, len(all)) 
Note: See TracChangeset for help on using the changeset viewer.