Changeset 245

Show
Ignore:
Timestamp:
01/01/06 17:47:40 (3 years ago)
Author:
eblot
Message:

LdapPlugin:

Throws TracError? if grant or remove permission command fails for some reason
Fixes up ldap server port handling
Fixes up plugin loader

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • ldapplugin/0.9/AUTHORS

    • Property svn:eol-style set to native
  • ldapplugin/0.9/COPYING

    • Property svn:eol-style set to native
  • ldapplugin/0.9/LdapPlugin.egg-info/trac_plugin.txt

    • Property svn:eol-style set to native
  • ldapplugin/0.9/ldapplugin/__init__.py

    • Property svn:eol-style set to native
    r135 r245  
    1 # -*- coding: iso-8859-1 -*- 
    2  
    3 # Ldap Plugin module 
    4 from model import * 
     1# Ldap Plugin python package 
     2from ldapplugin.model import * 
  • ldapplugin/0.9/ldapplugin/model.py

    • Property svn:eol-style set to native
    r234 r245  
    234234            self._openldap() 
    235235        uid = self._create_uid(username) 
    236         permlist = self._get_permissions(uid) 
    237         if action not in permlist: 
    238             self._ldap.add_attribute(uid, self._permattr, action) 
     236        try: 
     237            permlist = self._get_permissions(uid) 
     238            if action not in permlist: 
     239                self._ldap.add_attribute(uid, self._permattr, action) 
     240        except ldap.LDAPError, e: 
     241            raise TracError, "Unable to grant permission %s to %s: %s" \ 
     242                             % (action, username, e[0]['desc']) 
    239243 
    240244    def revoke_permission(self, username, action): 
     
    245249            self._openldap() 
    246250        uid = self._create_uid(username) 
    247         permlist = self._get_permissions(uid) 
    248         if action in permlist: 
    249             self._ldap.delete_attribute(uid, self._permattr, action) 
     251        try: 
     252            permlist = self._get_permissions(uid) 
     253            if action in permlist: 
     254                self._ldap.delete_attribute(uid, self._permattr, action) 
     255        except ldap.LDAPError, e: 
     256            raise TracError, "Unable to revoke permission %s to %s: %s" \ 
     257                             % (action, username, e[0]['desc']) 
    250258 
    251259    # Private implementation 
     
    306314        if not self.group_basedn: 
    307315            self.group_basedn = self.basedn 
     316        if not isinstance(self.port, int): 
     317            self.port = int(self.port) 
    308318        self._uid = None 
    309319        self._password = None 
     
    450460            dn = "%s,%s" % (uid, self.basedn) 
    451461            self._ds.modify_s(dn, [(ldap.MOD_ADD, attr, value)])  
    452             return True 
    453462 
    454463        except ldap.LDAPError, e: 
     
    456465                           (attr, uid, e[0]['desc'])) 
    457466            self._ds = False 
    458             return False; 
     467            raise e 
    459468 
    460469    def delete_attribute(self, uid, attr, value): 
     
    464473            dn = "%s,%s" % (uid, self.basedn) 
    465474            self._ds.modify_s(dn, [(ldap.MOD_DELETE, attr, value)])  
    466             return True 
    467475 
    468476        except ldap.LDAPError, e: 
     
    470478                           (attr, uid, e[0]['desc'])) 
    471479            self._ds = False 
    472             return False; 
    473  
     480            raise e 
     481 
  • ldapplugin/0.9/ldapplugin/tests/model.py

    • Property svn:eol-style set to native
  • ldapplugin/0.9/setup.py

    • Property svn:eol-style set to native
    r234 r245  
     1#!/usr/bin/env python 
     2 
    13from setuptools import setup, find_packages 
    24 
     5PACKAGE = 'LdapPlugin' 
     6VERSION = '0.2.3' 
     7 
    38setup ( 
    4     name = 'LdapPlugin', 
    5     version = "0.2.3", 
    6     packages = find_packages(), 
    7     package_data = {  
    8     }, 
     9    name = PACKAGE, 
     10    version = VERSION, 
     11    packages = find_packages(exclude=['ez_setup', '*.tests*']), 
     12    package_data = { }, 
    913    author = "Emmanuel Blot", 
    1014    author_email = "manu.blot@gmail.com", 
     
    1317    url = "http://trac-hacks.swapoff.org/wiki/LdapPlugin", 
    1418) 
     19