Skip to content

Instantly share code, notes, and snippets.



Last active Aug 29, 2015
What would you like to do?
Add Plone Members Programmatically, Tested on Plone 4.3.3. Prepare Your Own member.csv, and Run bin/plonectl run
from Products.CMFCore.utils import getToolByName
membership = getToolByName(app.mysite, 'portal_membership')
for member in membership.listMembers():
print member.getProperty('id'), member.getProperty('fullname'), member.getProperty('email')
user1 pass1 User One
user2 pass2 測試
from Testing import makerequest
root = makerequest.makerequest(app)
site = root.mysite
admin = root.acl_users.getUserById('admin')
admin = admin.__of__(site.acl_users)
from AccessControl.SecurityManagement import newSecurityManager
newSecurityManager(None, admin)
#from import setHooks
from import setSite
from Products.CMFCore.utils import getToolByName
regtool = getToolByName(site, 'portal_registration')
#username = 'testuser'
#password = 'topsecret'
#properties = {'username': username, 'fullname': 'Test User', 'email': ''}
import csv
with open('member.csv', 'rb') as f:
reader = csv.reader(f)
for row in reader:
#member = regtool.addMember(username, password, properties=properties)
member = regtool.addMember(row[0], row[1], properties={'username': row[0], 'fullname': row[2], 'email': row[3]})
import transaction
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.