Back to index

plone3  3.1.7
__init__.py
Go to the documentation of this file.
00001 # -*- coding: utf-8 -*-
00002 ## GroupUserFolder
00003 ## Copyright (C)2006 Ingeniweb
00004 
00005 ## This program is free software; you can redistribute it and/or modify
00006 ## it under the terms of the GNU General Public License as published by
00007 ## the Free Software Foundation; either version 2 of the License, or
00008 ## (at your option) any later version.
00009 
00010 ## This program is distributed in the hope that it will be useful,
00011 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 ## GNU General Public License for more details.
00014 
00015 ## You should have received a copy of the GNU General Public License
00016 ## along with this program; see the file COPYING. If not, write to the
00017 ## Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00018 """
00019 
00020 """
00021 __version__ = "$Revision:  $"
00022 # $Source:  $
00023 # $Id: __init__.py 40111 2007-04-01 09:12:57Z alecm $
00024 __docformat__ = 'restructuredtext'
00025 
00026 # postonly protections
00027 try:
00028     # Zope 2.8.9, 2.9.7 and 2.10.3 (and up)
00029     from AccessControl.requestmethod import postonly
00030 except ImportError:
00031     try:
00032         # Try the hotfix too
00033         from Products.Hotfix_20070320 import postonly
00034     except:
00035         def postonly(callable): return callable
00036 
00037 
00038 import GroupUserFolder
00039 import GRUFFolder
00040 try:
00041     import Products.LDAPUserFolder
00042     hasLDAP = 1
00043 except ImportError:
00044     hasLDAP = 0
00045 from global_symbols import *
00046 
00047 # Plone import try/except
00048 try:
00049     from Products.CMFCore.DirectoryView import registerDirectory
00050     import GroupsToolPermissions
00051 except:
00052     # No registerdir available -> we ignore
00053     pass
00054 
00055 # Used in Extension/install.py
00056 global groupuserfolder_globals
00057 groupuserfolder_globals=globals()
00058 
00059 # LDAPUserFolder patching
00060 if hasLDAP:
00061     import LDAPGroupFolder
00062     
00063     def patch_LDAPUF():
00064         # Now we can patch LDAPUF
00065         from Products.LDAPUserFolder import LDAPUserFolder
00066         import LDAPUserFolderAdapter
00067         LDAPUserFolder._doAddUser = LDAPUserFolderAdapter._doAddUser
00068         LDAPUserFolder._doDelUsers = LDAPUserFolderAdapter._doDelUsers
00069         LDAPUserFolder._doChangeUser = LDAPUserFolderAdapter._doChangeUser
00070         LDAPUserFolder._find_user_dn = LDAPUserFolderAdapter._find_user_dn
00071         LDAPUserFolder.manage_editGroupRoles = LDAPUserFolderAdapter.manage_editGroupRoles
00072         LDAPUserFolder._mangleRoles = LDAPUserFolderAdapter._mangleRoles
00073 
00074     # Patch LDAPUF  : XXX FIXME: have to find something cleaner here?
00075     patch_LDAPUF()
00076 
00077 def initialize(context):
00078 
00079     try:
00080         registerDirectory('skins', groupuserfolder_globals)
00081     except:
00082         # No registerdir available => we ignore
00083         pass
00084 
00085     context.registerClass(
00086         GroupUserFolder.GroupUserFolder,
00087         permission='Add GroupUserFolders',
00088         constructors=(GroupUserFolder.manage_addGroupUserFolder,),
00089         icon='www/GroupUserFolder.gif',
00090         )
00091 
00092     if hasLDAP:
00093         context.registerClass(
00094             LDAPGroupFolder.LDAPGroupFolder,
00095             permission='Add GroupUserFolders',
00096             constructors=(LDAPGroupFolder.addLDAPGroupFolderForm, LDAPGroupFolder.manage_addLDAPGroupFolder,),
00097             icon='www/LDAPGroupFolder.gif',
00098             )
00099 
00100     context.registerClass(
00101         GRUFFolder.GRUFUsers,
00102         permission='Add GroupUserFolder',
00103         constructors=(GRUFFolder.manage_addGRUFUsers,),
00104         visibility=None,
00105         icon='www/GRUFUsers.gif',
00106         )
00107 
00108     context.registerClass(
00109         GRUFFolder.GRUFGroups,
00110         permission='Add GroupUserFolder',
00111         constructors=(GRUFFolder.manage_addGRUFGroups,),
00112         visibility=None,
00113         icon='www/GRUFGroups.gif',
00114         )
00115 
00116     try:
00117         from Products.CMFCore.utils import ToolInit, ContentInit
00118         from GroupsTool import GroupsTool
00119         from GroupDataTool import GroupDataTool
00120         ToolInit( meta_type='CMF Groups Tool'
00121                   , tools=( GroupsTool, GroupDataTool, )
00122                   , icon="tool.gif"
00123                   ).initialize( context )
00124 
00125     except ImportError:
00126         Log(LOG_NOTICE, "Unable to import GroupsTool and/or GroupDataTool. \
00127         This won't disable GRUF but if you use CMF/Plone you won't get benefit of its special features.")