Changeset 50969

Show
Ignore:
Timestamp:
02/02/07 17:01:26 (3 years ago)
Author:
gracinet
Message:

#1810: Directories can be globally set to read-only

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • CPS3/products/CPSDirectory/trunk/BaseDirectory.py

    r48857 r50969  
    2020""" 
    2121 
    22 from zLOG import LOG, DEBUG 
     22from zLOG import LOG, DEBUG, INFO 
    2323 
    2424from urllib import urlencode 
     
    103103        {'id': 'layout', 'type': 'string', 'mode': 'w', 
    104104         'label': "Layout"}, 
     105        {'id': 'readonly', 'type': 'boolean', 'mode': 'w', 
     106         'label': "Is the directory read-only?",}, 
    105107        {'id': 'layout_search', 'type': 'string', 'mode': 'w', 
    106108         'label': "Layout for search"}, 
     
    131133    layout = '' 
    132134    layout_search = '' 
     135    readonly = False 
    133136    acl_directory_view_roles = 'Manager' 
    134137    acl_entry_create_roles = 'Manager' 
     
    501504        """Edit an entry in the directory, unrestricted. 
    502505        """ 
     506        if self.readonly: 
     507            LOG('BaseDirectory._editEntry', INFO, 
     508                'directory %s is readonly' % self.getId()) 
     509            return 
    503510        id = entry[self.id_field] 
    504511        dm = self._getDataModel(id, check_acls=check_acls) 
  • CPS3/products/CPSDirectory/trunk/CHANGES

    r50947 r50969  
    1717  but not to modify them. 
    1818- #1809: Cannot authenticate against very restricted LDAP server 
     19- #1810: Directories can be globally set to read-only 
    1920New internal features 
    2021~~~~~~~~~~~~~~~~~~~~~ 
  • CPS3/products/CPSDirectory/trunk/ZODBDirectory.py

    r34472 r50969  
    2020""" 
    2121 
    22 from zLOG import LOG, DEBUG, TRACE 
     22from zLOG import LOG, DEBUG, TRACE, INFO 
    2323 
    2424from cgi import escape 
     
    196196    def _editEntry(self, entry, check_acls=False): 
    197197        """ unrestricted method to edit an entry and invalidate the cache. """ 
     198        if self.readonly: 
     199            LOG('ZODBDirectory._editEntry', INFO, 
     200                'directory %s is readonly' % self.getId()) 
     201            return 
    198202        BaseDirectory._editEntry(self, entry, check_acls) 
    199203        self.ZCacheable_invalidate() 
  • CPS3/products/CPSDirectory/trunk/tests/testLDAPBackingDirectory.py

    r46647 r50969  
    10291029        self.assertEquals(entry, entry_def) 
    10301030 
    1031  
     1031        # readonly behavior 
     1032        self.dir.readonly = True 
     1033        self.dir.editEntry({'yetanotherfield': "Some junk"}) 
     1034        self.assertEquals(entry, entry_def) 
    10321035 
    10331036def test_suite(): 
  • CPS3/products/CPSDirectory/trunk/tests/testZODBDirectory.py

    r50847 r50969  
    517517        self.assert_(meth(id='peterpan')) 
    518518        self.assert_(meth(entry={'name': 'Peterpan'})) 
     519        # readonly behavior 
     520        self.dir.readonly = True 
     521        self.dir._editEntry({'name': 'Peterspoon', 'id': 'peterpan'}) 
     522        self.assertEquals(self.dir._getEntry('peterpan')['name'], 
     523                          'Peterpan') 
    519524 
    520525    def testBasicSecurity(self):