File: __init__.py

package info (click to toggle)
zope-ldapuserfolder 2.8~beta-1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 628 kB
  • ctags: 528
  • sloc: python: 4,921; xml: 68; makefile: 33
file content (80 lines) | stat: -rw-r--r-- 3,151 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
##############################################################################
#
# __init__.py	Initialization code for the LDAPUserFolder
#
# This software is governed by a license. See
# LICENSE.txt for the terms of this license.
# 
##############################################################################

__doc__     = """ LDAPUserFolder initialization module """
__version__ = '$Revision: 1371 $'[11:-2]

from AccessControl.Permissions import add_user_folders

from LDAPUserFolder import manage_addLDAPUserFolder, LDAPUserFolder
from LDAPUserSatellite import addLDAPUserSatelliteForm, \
                              manage_addLDAPUserSatellite, \
                              LDAPUserSatellite

try:
    from Products.CMFCore.DirectoryView import registerDirectory
    registerDirectory('skins', globals())

    try:
        from Products.GenericSetup import EXTENSION
        from Products.GenericSetup import profile_registry
        have_gs = True
    except ImportError:
        # CMF < 1.6
        from Products.CMFSetup import EXTENSION
        from Products.CMFSetup import profile_registry
        have_gs = False

    have_cmf = True
except ImportError:
    have_cmf = False


def initialize(context):
    context.registerClass( LDAPUserFolder
                         , permission=add_user_folders
                         , constructors=(manage_addLDAPUserFolder,)
                         , icon='www/ldapuserfolder.gif'
                         )

    context.registerClass( LDAPUserSatellite
                         , permission=add_user_folders
                         , constructors=( addLDAPUserSatelliteForm
                                        , manage_addLDAPUserSatellite
                                        )
                         , icon='www/ldapusersatellite.gif'
                         )

    context.registerHelp()

    if have_cmf:
        if not have_gs:
            profile_registry.registerProfile( 'default'
                                            , 'LDAPUserFolder CMF Tools'
                                            , 'Adds LDAP support to the CMF.'
                                            , 'profiles/default'
                                            , 'LDAPUserFolder'
                                            , EXTENSION
                                            )
        else:
            try:
                from Products.CMFCore.interfaces import ISiteRoot
                profile_registry.registerProfile( 'default'
                                                , 'LDAPUserFolder CMF Tools'
                                                , 'Adds LDAP support to the CMF.'
                                                , 'profiles/default'
                                                , 'LDAPUserFolder'
                                                , EXTENSION
                                                , for_=ISiteRoot
                                                )
            except ImportError:
                # Insane situation encountered: GS is available, but the CMF
                # version is < 1.6. Giving up.
                pass