This question has been flagged
3910 Views

im trying to create a site in alfresco with a python code ,the code itself works fine with static parameters but when i try to get the parameters from a wizard i got this error


# -*- coding: utf-8 -*-

from openerp.osv import fields, osv

import time

import requests

from json import JSONEncoder

class alfresco_passwordpass(osv.osv_memory):

_name = 'alfresco.passwordpass'

_columns = {

'name' : fields.char('alfrescoPwd2', size=30),

'visibility' : fields.char('alfrescoPwd3',size=30),

'description' : fields.char('alfrescoPwd4', size=30),

}

def create_site(self, cr, uid, ids,context=None):

s = requests.Session()

res_users_obj = self.pool.get('res.users')

listetest= res_users_obj.search(cr, uid, [], context=context)

res=res_users_obj.browse(listetest[0])

data = {'username':res.login, 'password':res.x_alfrescoPwd}

url = "http://127.0.0.1:8080/share/page/dologin"

r = s.post(url, data=data)

if (r.status_code != 200) :

print "Incorrect login or password "

get_response = s.get('http://127.0.0.1:8080/share/service/modules/authenticated?a=user')

if (get_response.status_code != 200) :

print " authentification failed"

url1='http://127.0.0.1:8080/share/service/modules/create-site'

data=self.browse(cr,uid,ids[0],context=context)

jsonString = JSONEncoder().encode({

"shortName": data.name,

"Visiblity": data.visibility,

"sitePreset": "site-dashboard",

"title" : data.name,

"description" : data.description

})

headers = {'content-type': 'application/json',"Accept":"application/json"}

site = s.post(url1,headers=headers,data=jsonString)

if (site.status_code != 200) :

print " Error while creating site"

return;

Avatar
Discard