chamilo.py 1.2 KB

123456789101112131415161718192021222324252627
  1. # This file can be used as a base to configure OpenERP's web service module
  2. # to connect to a Chamilo portal and make use of its SOAP services.
  3. # This file is useless here, and should be placed on the OpenERP side after
  4. # being correctly configured (change variables below) in order to be put
  5. # to good use
  6. # @author Gustavo Maggi - Latinux
  7. ## Configuration section - set the variables below to their right values
  8. # Chamilo's root directory URL. Replace by your own URL without the trailing /
  9. # Examples: http://campus.server.com or http://campus.server.com/chamilo
  10. url_root = 'http://192.168.1.1/chamilo'
  11. # Get the Chamilo secret API key
  12. # can be found in main/inc/conf/configuration.php, around line 115
  13. security_key= 'abcdef1234567890abcdef1234567890'
  14. ## Connexion preparation
  15. # Connexion - do not change anything here
  16. from SOAPpy import SOAPProxy
  17. server = SOAPProxy(url_root+'/main/webservices/soap.php' )
  18. # Import libraries to calculate the SHA1 hash
  19. import hashlib
  20. import urllib2 as wget
  21. # Get the IP of the current host, as detected by Chamilo (testip.php)
  22. my_ip = wget.urlopen(url_root+'/main/webservices/testip.php').readlines()[0][:-1]
  23. # Get the secret key - now the Chamilo webservices can be called
  24. secret_key = hashlib.sha1(my_ip+security_key).hexdigest()