-
Notifications
You must be signed in to change notification settings - Fork 1
/
add_openplans.py
29 lines (23 loc) · 1.01 KB
/
add_openplans.py
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
from AccessControl.SecurityManagement import newSecurityManager
from Testing.makerequest import makerequest
from opencore.utility.interfaces import IProvideSiteConfig
from zope.component import getUtility
import transaction
app=makerequest(app)
config = getUtility(IProvideSiteConfig)
admin_file = config.get('admin_info_filename', default='admin')
admin_id = open(admin_file).read().split(':')[0]
site_id = config.get('opencore_site_id', default='openplans')
site_title = config.get('opencore_site_title', default='OpenCore Site')
if site_id in app.objectIds():
print "Site %s already exists, nothing to do" % site_id
else:
print "Creating site %s" % site_id
user = app.acl_users.getUser(admin_id)
user = user.__of__(app.acl_users)
newSecurityManager(app, user)
profiles = ('opencore.configuration:default',)
factory = app.manage_addProduct['CMFPlone'].addPloneSite
factory(site_id, site_title, extension_ids=profiles)
transaction.get().note('Adding openplans site')
transaction.commit()