Creating Users and Sites
Prev | Chapter 1. 20 Minute Quick Start | Next

## Creating Users and Sites

To demonstrate writing a client, we will write a python script that adds a few users to Sakai, and then creates a site for them. First, the entire contents of the example script.

    import os
    import sys
    from SOAPpy import WSDL

    login_url = "http://localhost:8080/sakai-axis/SakaiLogin.jws?wsdl"
    script_url = "http://localhost:8080/sakai-axis/SakaiScript.jws?wsdl"

    login_proxy = WSDL.SOAPProxy(login_url)
    script_proxy = WSDL.SOAPProxy(script_url)

    loginsoap = WSDL.SOAPProxy(login_url)
    scriptsoap = WSDL.SOAPProxy(script_url)

    sessionid = loginsoap.login("admin", "admin")

    print scriptsoap.addNewUser(sessionid, "teacher", "Bob", "Smith", "bob@pedagogy.edu", "", "password" )
    print scriptsoap.addNewUser(sessionid, "student1", "Laura", "Hope", "laura@pedagogy.edu", "", "password"
    print scriptsoap.addNewUser(sessionid, "student2", "Sam", "Goodman", "bob@pedagogy.edu", "", "password" )
    print scriptsoap.addNewSite(sessionid, "psych101", "Psych 101 ", "Psychology", \
                                "Psych", "", "", True, "access", True, True, "", "" )

    print scriptsoap.addNewPageToSite(sessionid, "psych101", "Announcements", 0)
    print scriptsoap.addNewToolToPage(sessionid, "psych101", "Announcements", "Announcements", "sakai.announc
    print scriptsoap.addMemberToSiteWithRole(sessionid, "psych101", "teacher", "maintain")
    print scriptsoap.addMemberToSiteWithRole(sessionid, "psych101", "student1", "access")
    print scriptsoap.addMemberToSiteWithRole(sessionid, "psych101", "student2", "access")

Running this script on the command line will show results something like:

    sgithens@thumbtack$ python QuickExample.py
    success
    success
    success
    success
    success
    success
    success
    success
    sgithens@thumbtack$

Prev | Up | Next
Where are the web services? | Home | Chapter 2. Getting Started