# HG changeset patch # User neko259 # Date 2016-05-09 16:24:47 # Node ID a596995db5fd80c7dcaef11d3f8287d7b761f4d4 # Parent 9b4affd0eb92e61aa4c5f0e8c8e86eb6b3b2993f Added limit option to sync command diff --git a/boards/management/commands/sync_with_server.py b/boards/management/commands/sync_with_server.py --- a/boards/management/commands/sync_with_server.py +++ b/boards/management/commands/sync_with_server.py @@ -20,6 +20,9 @@ class Command(BaseCommand): parser.add_argument('url', type=str, help='Server root url') parser.add_argument('--global-id', type=str, default='', help='Post global ID') + parser.add_argument('--split-query', type=int, + help='Split GET query into separate by the given' + ' number of posts in one') def handle(self, *args, **options): url = options.get('url') @@ -68,12 +71,14 @@ class Command(BaseCommand): print() if len(ids_to_sync) > 0: - xml = GlobalId.objects.generate_request_get(ids_to_sync) - # body = urllib.parse.urlencode(data) - h = httplib2.Http() - response, content = h.request(get_url, method="POST", body=xml) + limit = options.get('split_query', len(ids_to_sync)) + for offset in range(0, len(ids_to_sync), limit): + xml = GlobalId.objects.generate_request_get(ids_to_sync[offset:offset+limit0]) + # body = urllib.parse.urlencode(data) + h = httplib2.Http() + response, content = h.request(get_url, method="POST", body=xml) - SyncManager.parse_response_get(content, file_url) + SyncManager.parse_response_get(content, file_url) else: print('Nothing to get, everything synced') else: