paula: removed old per-repo trunk subdirs
[paula.git] / paula.suite / src / paula / suite / __init__.py
blobfdd58bf3370dd0995f7542aaf887b9b6bb72faa5
1 # Copyright (c) 2008 by Florian Friesdorf
3 # GNU Affero General Public License (AGPL)
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU Affero General Public License as
7 # published by the Free Software Foundation; either version 3 of the
8 # License, or (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU Affero General Public License for more details.
15 # You should have received a copy of the GNU Affero General Public
16 # License along with this program. If not, see
17 # <http://www.gnu.org/licenses/>.
18 """
19 """
20 __author__ = "Florian Friesdorf <flo@chaoflow.net>"
21 __docformat__ = "plaintext"
23 from zope.app.authentication import principalfolder
24 from zope.app.authentication.authentication import PluggableAuthentication
25 from zope.app.authentication.interfaces import IPluggableAuthentication
27 from zope.app.security.interfaces import IAuthentication
28 from zope.app.folder import Folder
30 from zope.component import getSiteManager, provideAdapter
32 from paula.authentication import LocalAuthenticatorPlugin
33 from paula.authentication import CredentialsFromMappingPlugin
34 from paula.authentication.interfaces import ILocalAuthenticatorPlugin
35 from paula.authentication.interfaces import ICredentialsFromMappingPlugin
37 from paula.authutil import RWAuthProviders
38 from paula.authutil.interfaces import IRWAuthProviders
40 from paula.proputil import RWPropertyProviders
41 from paula.proputil.interfaces import IRWPropertyProviders
43 from config import PAULA_AUTHPLUGIN_NAME
44 from config import PAULA_CREDPLUGIN_NAME
46 from persistent import Persistent
48 #def createPaulaSuite(container=None, create_pau=False, create_credplug=False):
49 def createPaulaSuite(container, create_pau=False, create_credplugin=False,
50 ContainerType=None):
51 """Creates paula components in the given container and registers them
52 """
53 sm = getSiteManager(container)
55 if create_pau and not 'paula_pau' in container:
56 try:
57 from OFS.SimpleItem import Item
58 import Acquisition
59 import AccessControl.Role
60 except ImportError:
61 MyPluggableAuthentication = PluggableAuthentication
62 else:
63 class MyPluggableAuthentication(
64 PluggableAuthentication,
65 Item,
66 Acquisition.Implicit,
67 AccessControl.Role.RoleManager,
69 def __init__(self):
70 super(MyPluggableAuthentication, self).__init__()
71 pau = MyPluggableAuthentication()
72 container['paula_pau'] = pau
74 # register PAU as IAuthentication and IPluggableAuthentication
75 sm = getSiteManager(container)
76 sm.registerUtility(pau, IAuthentication)
77 sm.registerUtility(pau, IPluggableAuthentication)
79 # register principal factories needed by PAU
80 # XXX: bug in zope.app.authentication, we need to register globally
81 #sm.registerAdapter(principalfolder.AuthenticatedPrincipalFactory)
82 #sm.registerAdapter(principalfolder.FoundPrincipalFactory)
83 provideAdapter(principalfolder.AuthenticatedPrincipalFactory)
84 provideAdapter(principalfolder.FoundPrincipalFactory)
86 pau = sm.getUtility(IPluggableAuthentication)
88 # Paula's PAU AuthenticatorPlugin
89 if not 'paula_authplugin' in container:
90 authplugin = LocalAuthenticatorPlugin()
91 container['paula_authplugin'] = authplugin
92 sm.registerUtility( authplugin,
93 ILocalAuthenticatorPlugin,
94 name=PAULA_AUTHPLUGIN_NAME,
96 pau.authenticatorPlugins += (PAULA_AUTHPLUGIN_NAME,)
98 if create_credplugin and not 'paula_credplugin' in container:
99 credplugin = CredentialsFromMappingPlugin()
100 container['paula_credplugin'] = credplugin
101 sm.registerUtility( credplugin,
102 ICredentialsFromMappingPlugin,
103 name=PAULA_CREDPLUGIN_NAME,
105 pau.credentialsPlugins += (PAULA_CREDPLUGIN_NAME,)
107 if not 'authutil' in container:
108 authutil = RWAuthProviders()
109 container['paula_authutil'] = authutil
110 sm.registerUtility( authutil, IRWAuthProviders)
112 if not 'paula_proputil' in container:
113 proputil = RWPropertyProviders()
114 container['paula_proputil'] = proputil
115 sm.registerUtility( proputil, IRWPropertyProviders)