Show More
@@ -39,7 +39,7 b' class Command(BaseCommand):' | |||
|
39 | 39 | h = httplib2.Http() |
|
40 | 40 | response, content = h.request(url, method="POST", body=xml) |
|
41 | 41 | |
|
42 |
SyncManager |
|
|
42 | SyncManager.parse_response_get(content) | |
|
43 | 43 | else: |
|
44 | 44 | raise Exception('Invalid global ID') |
|
45 | 45 | else: |
@@ -31,9 +31,9 b" ATTR_MIMETYPE = 'mimetype'" | |||
|
31 | 31 | STATUS_SUCCESS = 'success' |
|
32 | 32 | |
|
33 | 33 | |
|
34 | # TODO Make this fully static | |
|
35 | 34 | class SyncManager: |
|
36 | def generate_response_get(self, model_list: list): | |
|
35 | @staticmethod | |
|
36 | def generate_response_get(model_list: list): | |
|
37 | 37 | response = et.Element(TAG_RESPONSE) |
|
38 | 38 | |
|
39 | 39 | status = et.SubElement(response, TAG_STATUS) |
@@ -88,8 +88,9 b' class SyncManager:' | |||
|
88 | 88 | |
|
89 | 89 | return et.tostring(response, ENCODING_UNICODE) |
|
90 | 90 | |
|
91 | @staticmethod | |
|
91 | 92 | @transaction.atomic |
|
92 |
def parse_response_get( |
|
|
93 | def parse_response_get(response_xml): | |
|
93 | 94 | tag_root = et.fromstring(response_xml) |
|
94 | 95 | tag_status = tag_root.find(TAG_STATUS) |
|
95 | 96 | if STATUS_SUCCESS == tag_status.text: |
@@ -56,7 +56,7 b' class KeyTest(TestCase):' | |||
|
56 | 56 | text='[post]%d[/post]' % post.id, |
|
57 | 57 | thread=post.get_thread()) |
|
58 | 58 | |
|
59 |
response = SyncManager |
|
|
59 | response = SyncManager.generate_response_get([reply_post]) | |
|
60 | 60 | logger.debug(response) |
|
61 | 61 | |
|
62 | 62 | key = KeyPair.objects.get(primary=True) |
@@ -51,10 +51,10 b' class SyncTest(TestCase):' | |||
|
51 | 51 | |
|
52 | 52 | post.delete() |
|
53 | 53 | |
|
54 |
SyncManager |
|
|
54 | SyncManager.parse_response_get(response) | |
|
55 | 55 | self.assertEqual(1, Post.objects.count(), |
|
56 | 56 | 'Post was not created from XML response.') |
|
57 | 57 | |
|
58 |
SyncManager |
|
|
58 | SyncManager.parse_response_get(response) | |
|
59 | 59 | self.assertEqual(1, Post.objects.count(), |
|
60 | 60 | 'The same post was imported twice.') |
@@ -254,5 +254,5 b' def sync_pull(request):' | |||
|
254 | 254 | else: |
|
255 | 255 | pass # TODO Parse the XML and get filters from it |
|
256 | 256 | |
|
257 |
xml = SyncManager |
|
|
257 | xml = SyncManager.generate_response_get(posts) | |
|
258 | 258 | return HttpResponse(content=xml) |
@@ -28,7 +28,7 b' def response_get(request):' | |||
|
28 | 28 | if exists: |
|
29 | 29 | posts.append(Post.objects.get(global_id=global_id)) |
|
30 | 30 | |
|
31 |
response_xml = SyncManager |
|
|
31 | response_xml = SyncManager.generate_response_get(posts) | |
|
32 | 32 | |
|
33 | 33 | return HttpResponse(content=response_xml) |
|
34 | 34 | |
@@ -40,7 +40,7 b' def get_post_sync_data(request, post_id)' | |||
|
40 | 40 | raise Http404() |
|
41 | 41 | |
|
42 | 42 | content = 'Global ID: %s\n\nXML: %s' \ |
|
43 |
% (post.global_id, SyncManager |
|
|
43 | % (post.global_id, SyncManager.generate_response_get([post])) | |
|
44 | 44 | |
|
45 | 45 | |
|
46 | 46 | return HttpResponse( |
General Comments 0
You need to be logged in to leave comments.
Login now