Пример #1
0
usersByName['reduce'] = "_count"

args = common.parse_args()
conn = common.get_connection(args.use_ssl, args.couch_server, args.couch_port)

credentials = common.get_credentials(args.adminuser, args.adminpass)
get_headers = common.get_headers(credentials)
put_headers = common.put_headers(credentials)

conn.connect()

#Update the _users design document
ddoc_uri = '/_users/_design/' + user_ddoc
conn.request("GET", ddoc_uri, headers=get_headers)
resp = conn.getresponse()
if resp.getcode() != 200:
    print("Fetch of user design doc failed")
    sys.exit(1)
ddoc = common.decode_response(resp)
ddoc['views']['usersByName'] = usersByName
req_body = json.dumps(ddoc)
conn.request("PUT", ddoc_uri, body=req_body, headers=put_headers)
resp = conn.getresponse()
resp_body = common.decode_response(resp)

if resp.getcode() == 201:
    print("Update of user design doc successful")
else:
    print("Update of the user design doc failed.")
Пример #2
0
    }
}
"""

getImageFileIndex['reduce'] = "_count"

args = common.parse_args()
conn = common.get_connection(args.use_ssl, args.couch_server, args.couch_port)

credentials = common.get_credentials(args.adminuser, args.adminpass)
get_headers = common.get_headers(credentials)
put_headers = common.put_headers(credentials)

# Update all the wiki design docs
conn.request("GET", '/_all_dbs', headers=get_headers)
db_list = common.decode_response(conn.getresponse())
wiki_list = [db for db in db_list if db[0:5] == "wiki_"]

# Update the wiki dbs
for wiki in wiki_list:
    print("Examining " + wiki)
    # Fetch design doc
    ddoc_uri = '/' + wiki + '/_design/' + wiki_ddoc
    conn.request("GET", ddoc_uri, headers=get_headers)
    resp = conn.getresponse()
    ddoc = common.decode_response(resp)
    print("Updating " + wiki)
    ddoc['views']['getImageFileIndex'] = getImageFileIndex
    req_body = json.dumps(ddoc)
    conn.request("PUT", ddoc_uri, body=req_body, headers=put_headers)
    resp = conn.getresponse()
Пример #3
0
usersByName['reduce'] = "_count"

args = common.parse_args()
conn = common.get_connection(args.use_ssl, args.couch_server, args.couch_port)

credentials = common.get_credentials(args.adminuser, args.adminpass)
get_headers = common.get_headers(credentials)
put_headers = common.put_headers(credentials)

conn.connect()

#Update the _users design document
ddoc_uri = '/_users/_design/' + user_ddoc
conn.request("GET", ddoc_uri, headers=get_headers)
resp = conn.getresponse()
if resp.getcode() != 200:
    print("Fetch of user design doc failed")
    sys.exit(1)
ddoc = common.decode_response(resp)
ddoc['views']['usersByName'] = usersByName
req_body = json.dumps(ddoc)
conn.request("PUT", ddoc_uri, body=req_body, headers=put_headers)
resp = conn.getresponse()
resp_body = common.decode_response(resp)

if resp.getcode() == 201:
    print("Update of user design doc successful")
else:
    print("Update of the user design doc failed.")