From b6361cb073e1241c2b017f82aea7956cbd8f4a70 Mon Sep 17 00:00:00 2001 From: "Kevin S. Hahn" <kevinshahn@gmail.com> Date: Thu, 26 Feb 2015 13:58:44 -0800 Subject: [PATCH] rename remotes collection to sites for clarity - the collection contains information about all sites, including local site, not just remote sites. --- api.wsgi | 2 +- centralclient.py | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/api.wsgi b/api.wsgi index 908686de..08caff2a 100644 --- a/api.wsgi +++ b/api.wsgi @@ -18,7 +18,7 @@ ap.add_argument('--db_uri', help='SciTran DB URI', required=True) ap.add_argument('--data_path', help='path to storage area', required=True) ap.add_argument('--ssl_cert', help='path to SSL certificate file, containing private key and certificate chain', required=True) ap.add_argument('--api_uri', help='api uri, with https:// prefix') -ap.add_argument('--site_id', help='site ID for Scitran Central') +ap.add_argument('--site_id', help='site ID for Scitran Central [local]', default='local') ap.add_argument('--site_name', help='site name') ap.add_argument('--oauth2_id_endpoint', help='OAuth2 provider ID endpoint', default='https://www.googleapis.com/plus/v1/people/me/openIdConnect') ap.add_argument('--demo', help='enable automatic user creation', action='store_true', default=False) diff --git a/centralclient.py b/centralclient.py index 54dea35b..0168d445 100755 --- a/centralclient.py +++ b/centralclient.py @@ -51,8 +51,8 @@ def update(db, api_uri, site_name, site_id, ssl_cert, central_url): for _id, remotes in response['users'].iteritems(): db.users.update({'_id': _id}, {'$set': {'remotes': remotes}}) if sites: - db.remotes.remove({'_id': {'$nin': [site['_id'] for site in response['sites']]}}) - [db.remotes.update({'_id': site['_id']}, site, upsert=True) for site in sites] + db.sites.remove({'_id': {'$nin': [site['_id'] for site in response['sites']]}}) + [db.sites.update({'_id': site['_id']}, site, upsert=True) for site in sites] db.users.update( # clean users who no longer have remotes {'remotes': {'$exists': True}, '_id': {'$nin': users.keys()}}, {'$unset': {'remotes': ''}}, @@ -60,7 +60,7 @@ def update(db, api_uri, site_name, site_id, ssl_cert, central_url): ) log.info('%3d users with remote data, %3d remotes' % ( len([u['_id'] for u in db.users.find({'remotes': {'$exists': True}}, {'_id': True})]), - len([s['_id'] for s in db.remotes.find({}, {'_id': True})]) + len([s['_id'] for s in db.sites.find({}, {'_id': True})]) )) return True else: @@ -76,9 +76,9 @@ def update(db, api_uri, site_name, site_id, ssl_cert, central_url): def clean_remotes(db): - """Remove db.remotes, and removes remotes field from all db.users.""" + """Remove db.sites, and removes remotes field from all db.users.""" log.debug('removing remotes from users, and remotes collection') - db.remotes.remove({}) + db.sites.remove({}) db.users.update({'remotes': {'$exists': True}}, {'$unset': {'remotes': ''}}, multi=True) -- GitLab