Changeset 241


Ignore:
Timestamp:
05/16/06 08:48:41 (14 years ago)
Author:
vahur
Message:

random improvements. failing safely when remote servers are down or name resolving isn't working.
Also fixes some tests - since collections are realying heavily on user's home folder and collections folder that is
inside user's home folder, tests must log in. Need to write tests that test collections folder existence.
Limited LeMill search to our types.

Location:
trunk
Files:
16 edited

Legend:

Unmodified
Added
Removed
  • trunk/Activity.py

    r239 r241  
    6262    archetype_name = "Activity"   
    6363 
    64     def setCoverImage(self, value, **kwargs): 
    65         """ This modification for a mutator flags object to have a coverImage """     
    66         cover=self.getField('coverImage') 
    67         cover.set(self,value,**kwargs) 
    68         has_cover=self.getField('hasCoverImage') 
    69         has_cover.set(self,True)  
    70      
    7164registerType(Activity, PROJECTNAME) 
  • trunk/LeMillSearchTool.py

    r236 r241  
    2626from ZODB.PersistentMapping import PersistentMapping 
    2727import xmlrpclib 
     28from socket import gaierror 
     29from xmlrpclib import ProtocolError 
    2830from Acquisition import aq_base 
    2931from config import MANAGE_PORTAL 
     
    6769 
    6870        results = [] 
     71        if not kw.has_key('portal_type'): 
     72            # limiting search results to meta_types listed below. I wouldn't want junk on my way 
     73            kw['portal_type'] = ['Piece', 'Material', 'Tool', 'Story', 'Activity'] 
    6974        local = self.local_search(REQUEST, **kw) 
    7075        remote = [] 
     
    167172        address = address +'/'+ self.getId() 
    168173        r = xmlrpclib.Server(address) 
    169         remote = r.pong('ping') 
     174        try: 
     175            remote = r.pong('ping') 
     176        except (ProtocolError, gaierror): 
     177            #print "incompatible server or failure in name resolution" 
     178            return 1 
    170179        if remote != 'pong': 
    171180            return 1 
     
    253262        return uniquetuplelist 
    254263 
    255  
    256  
    257  
    258  
    259264InitializeClass(LeMillSearchTool) 
  • trunk/Material.py

    r239 r241  
    120120    meta_type = "Material" 
    121121    archetype_name = "Material"   
     122    security = ClassSecurityInfo() 
     123    security.declareObjectPublic() 
    122124 
    123125    def getPieces(self): 
     
    250252        return self.base_edit() 
    251253 
    252     def setCoverImage(self, value, **kwargs): 
    253         """ This modification for a mutator flags object to have a coverImage """ 
    254         cover=self.getField('coverImage') 
    255         cover.set(self,value,**kwargs) 
    256         has_cover=self.getField('hasCoverImage') 
    257         has_cover.set(self,True)  
    258  
    259  
    260254registerType(Material, PROJECTNAME) 
  • trunk/Piece.py

    r240 r241  
    4444    meta_type = "Piece" 
    4545    archetype_name = "Piece"   
     46    security = ClassSecurityInfo() 
     47    security.declareObjectPublic() 
    4648 
    4749    # Use the file as cover image, if it's an image 
     
    5860            has_cover.set(self,True)  
    5961 
    60     def setCoverImage(self, value, **kwargs): 
    61         """ This modification for a mutator flags object to have a coverImage """     
    62         cover=self.getField('coverImage') 
    63         cover.set(self,value,**kwargs) 
    64         has_cover=self.getField('hasCoverImage') 
    65         has_cover.set(self,True)  
    66          
    6762registerType(Piece, PROJECTNAME) 
  • trunk/Resources.py

    r236 r241  
    4545        return 'default_%s.png' % self.meta_type.lower() 
    4646 
     47    def setCoverImage(self, value, **kwargs): 
     48        """ This modification for a mutator flags object to have a coverImage """ 
     49        cover=self.getField('coverImage') 
     50        cover.set(self,value,**kwargs) 
     51        has_cover=self.getField('hasCoverImage') 
     52        has_cover.set(self,True) 
     53         
     54    def getCollectionsFolder(self): 
     55        """ return collections folder. Will return object' owner collections folder """ 
     56        home = self.portal_membership.getHomeFolder(str(self.getOwner())) 
     57        if not home: 
     58            return None 
     59        return home.getCollectionsFolder() 
     60 
    4761class LearningResource(Resource): 
    4862    """Superclass for all learning resources (material, activity, tool).""" 
  • trunk/Story.py

    r236 r241  
    135135    archetype_name = "Story"   
    136136    global_allow = 1 
     137    security = ClassSecurityInfo() 
     138    security.declareObjectPublic() 
    137139 
    138140 
  • trunk/Tool.py

    r239 r241  
    3333    meta_type = "Tool" 
    3434    archetype_name = "Tool"   
    35      
    36     def setCoverImage(self, value, **kwargs): 
    37         """ This modification for a mutator flags object to have a coverImage """     
    38         cover=self.getField('coverImage') 
    39         cover.set(self,value,**kwargs) 
    40         has_cover=self.getField('hasCoverImage') 
    41         has_cover.set(self,True)  
    42  
     35    security = ClassSecurityInfo() 
     36    security.declareObjectPublic() 
    4337     
    4438registerType(Tool, PROJECTNAME) 
  • trunk/config.py

    r239 r241  
    3030 
    3131# 
    32 REMOTE_SERVERS = ["http://goedel.uiah.fi/lemill/"]  
     32REMOTE_SERVERS = ["http://lemill.net"]  
    3333 
    3434# Skin variations. The first one will be the defaul 
  • trunk/skins/lemill/portlet_activity_actions.pt

    r236 r241  
    55<div metal:define-macro="portlet" id="portlet-material-actions"> 
    66<tal:def define="isOwner python:context.checkOwner(request, context); 
    7     self_url context/absolute_url"> 
     7    self_url context/absolute_url; 
     8    colls context/getCollectionsFolder | nothing;"> 
    89 
    910<div class="tb-portlet" metal:use-macro="here/portlet_material_actions/macros/image_div"/> 
  • trunk/skins/lemill/portlet_material_actions.pt

    r238 r241  
    66<tal:def define="isOwner python:context.checkOwner(request, context); 
    77    self_url context/absolute_url; 
    8     colls python:mtool.getHomeFolder().getCollectionsFolder()"> 
     8    colls context/getCollectionsFolder | nothing;"> 
    99 
    1010<div class="tb-portlet" metal:define-macro="image_div"> 
     
    5050        <li tal:condition="not:isAnon"><a href="" tal:attributes="href python:str(here.absolute_url())+'/collection_add'">Add to collection</a></li> 
    5151        <!-- 2 li's displayed for all users --> 
    52         <li> 
    53         <a href="" tal:attributes="href string:${colls/absolute_url}?obj_id=${context/getId}">View collections</a>  
    54         <span tal:replace="python:'('+str(len(colls.getCollections(context.getId())))+')'">(1)</span> 
     52        <li tal:condition="colls"> 
     53            <a href=""  
     54                tal:attributes="href string:${colls/absolute_url}?obj_id=${context/getId}"> 
     55                View collections 
     56            </a>  
     57            <span tal:replace="python:'('+str(len(colls.getCollections(context.getId())))+')'">(1)</span> 
    5558        </li> 
    5659    </tal:macro> 
  • trunk/skins/lemill/portlet_piece_actions.pt

    r238 r241  
    66<tal:def define="isOwner python:context.checkOwner(request, context); 
    77    self_url context/absolute_url; 
    8     colls python:mtool.getHomeFolder().getCollectionsFolder()"> 
     8    colls context/getCollectionsFolder | nothing"> 
    99 
    1010<div class="tb-portlet" metal:use-macro="here/portlet_material_actions/macros/image_div"/> 
  • trunk/skins/lemill/portlet_tool_actions.pt

    r236 r241  
    55<div metal:define-macro="portlet" id="portlet-material-actions"> 
    66<tal:def define="isOwner python:context.checkOwner(request, context); 
    7     self_url context/absolute_url"> 
     7    self_url context/absolute_url; 
     8    colls context/getCollectionsFolder | nothing;"> 
    89 
    910<div class="tb-portlet" metal:use-macro="here/portlet_material_actions/macros/image_div"/> 
  • trunk/tests/testDeletePublish.py

    r236 r241  
    2323import os, sys, re 
    2424if __name__ == '__main__': 
    25     execfile(os.path.join(sys.path[0], 'framework.py')) 
     25        execfile(os.path.join(sys.path[0], 'framework.py')) 
    2626 
    2727from Testing import ZopeTestCase 
     
    3737class TestDeletePublish(LeMillTestCase,Functional): 
    3838 
    39     def afterSetUp(self): 
    40         self.addUser('foobarmanager','foobarmanager') 
    41          
    42          
    43     def testDeletePublish(self): 
    44         ob=self.construct('Piece', 'Mirci' ,self.folder) 
    45         ob.content_status_modify(workflow_action='publish') 
    46         path='/'.join((self.folder.absolute_url_path(),'Mirci')) 
    47         auth="test_user_1_:secret" 
    48         result=self.publish(path,basic=auth).getBody() 
    49         self.failUnless(re.search("Delete", result)) 
    50         self.gruf = self.folder.acl_users                
    51         self.gruf.userFolderAddUser('manager', 'secret', ('Manager',), (), (), ) 
    52         manager_auth="manager:secret"  
    53         result2=self.publish(path,basic=manager_auth).getBody() 
    54         self.failUnless(re.search("Delete", result2)) 
    55          
     39    def afterSetUp(self): 
     40        self.addUser('foobarmanager','foobarmanager') 
     41  
     42    def testDeletePublish(self): 
     43        ob=self.construct('Piece', 'Mirci' ,self.folder) 
     44        ob.content_status_modify(workflow_action='publish') 
     45        path='/'.join((self.folder.absolute_url_path(),'Mirci')) 
     46        auth="test_user_1_:secret" 
     47        result=self.publish(path,basic=auth).getBody() 
     48        self.failUnless(re.search("Hide", result), 'XXX: fixme') 
     49        self.gruf = self.folder.acl_users                                
     50        self.gruf.userFolderAddUser('manager', 'secret', ('Manager',), (), (), ) 
     51        manager_auth="manager:secret"  
     52        result2=self.publish(path,basic=manager_auth).getBody() 
     53        self.failUnless(re.search("Hide", result2)) 
     54                 
    5655def test_suite(): 
    57     from unittest import TestSuite, makeSuite 
    58     suite = TestSuite() 
    59     suite.addTest(makeSuite(TestDeletePublish)) 
    60     return suite 
     56    from unittest import TestSuite, makeSuite 
     57    suite = TestSuite() 
     58    suite.addTest(makeSuite(TestDeletePublish)) 
     59    return suite 
    6160 
    6261if __name__ == '__main__': 
    63     framework() 
     62        framework() 
  • trunk/tests/testMaterial.py

    r236 r241  
    3838 
    3939    def afterSetUp(self): 
    40         pass 
     40        self.addUser('foobar','foobar', ('Member',)) 
     41        #self.auth = "foorbar:foorbar" 
     42        self.loginAsPortalOwner() 
    4143 
    4244    def testExistence(self): 
     
    4749 
    4850    def testPortletExistence(self): 
     51        auth="foobar:foobar" 
     52        self.login('foobar') 
    4953        material = self.construct('Material', 'TestMaterial' ,self.portal.content) 
    5054        page = self.publish(material.absolute_url_path()+'/view', basic=auth).getBody() 
     
    8993 
    9094    def afterSetUp(self): 
     95        self.loginAsPortalOwner() 
    9196        self.ID='TestMaterial' 
    9297        self.ob=self.construct('Material',self.ID,self.folder) 
     
    111116        #self.login('foobar') 
    112117        auth="foobar:foobar" 
     118        self.login('foobar') 
    113119        path='/'.join((self.folder.absolute_url_path(),self.ID)) 
    114120        result=self.publish(path,basic=auth).getBody() 
     
    127133    def testUseUI(self): 
    128134        auth="foobar:foobar" 
     135        self.login('foobar') 
    129136        path='/'.join((self.folder.absolute_url_path(),self.ID)) 
    130137        result=self.publish(path,basic=auth).getBody() 
  • trunk/tests/testPiece.py

    r236 r241  
    4040 
    4141    def afterSetUp(self): 
    42         pass 
     42        self.loginAsPortalOwner() 
    4343 
    4444    def testExistence(self): 
     
    5757 
    5858    def testWCAGLogo(self): 
    59         ob=self.construct('Piece', 'TestPiece4' ,self.folder) 
    60         path='/'.join((self.folder.absolute_url_path(),'TestPiece4')) 
    61         result=self.publish(path).getBody() 
    62         self.failUnless(re.search("Explanation of Level Double-A Conformance", result)) 
     59        ob = self.construct('Piece', 'TestPiece4' ,self.folder) 
     60        #path='/'.join((self.folder.absolute_url_path(),'TestPiece4')) 
     61        path = ob.absolute_url_path()+'/view' 
     62        result = self.publish(path).getBody() 
     63        self.failUnless(re.search("Explanation of Level Double-A Conformance", result), "WCAG log not found? It may be possible that user doesn't have access to view object.") 
    6364 
    6465def test_suite(): 
  • trunk/tests/testWorkflow.py

    r236 r241  
    2828     
    2929    def afterSetUp(self): 
     30        self.loginAsPortalOwner() 
    3031        self.workflow = self.portal.portal_workflow 
    3132         
Note: See TracChangeset for help on using the changeset viewer.