##// END OF EJS Templates
Rename "pull" request to "list"
neko259 -
r1566:a1b54223 default
parent child Browse files
Show More
@@ -27,7 +27,7 b' class Command(BaseCommand):'
27 def handle(self, *args, **options):
27 def handle(self, *args, **options):
28 url = options.get('url')
28 url = options.get('url')
29
29
30 pull_url = url + 'api/sync/pull/'
30 list_url = url + 'api/sync/list/'
31 get_url = url + 'api/sync/get/'
31 get_url = url + 'api/sync/get/'
32 file_url = url[:-1]
32 file_url = url[:-1]
33
33
@@ -52,8 +52,8 b' class Command(BaseCommand):'
52 raise Exception('Invalid global ID')
52 raise Exception('Invalid global ID')
53 else:
53 else:
54 h = httplib2.Http()
54 h = httplib2.Http()
55 xml = GlobalId.objects.generate_request_pull()
55 xml = GlobalId.objects.generate_request_list()
56 response, content = h.request(pull_url, method="POST", body=xml)
56 response, content = h.request(list_url, method="POST", body=xml)
57
57
58 print(content.decode() + '\n')
58 print(content.decode() + '\n')
59
59
@@ -231,7 +231,7 b' class SyncManager:'
231 raise SyncException(EXCEPTION_NODE.format(tag_status.text))
231 raise SyncException(EXCEPTION_NODE.format(tag_status.text))
232
232
233 @staticmethod
233 @staticmethod
234 def generate_response_pull():
234 def generate_response_list():
235 response = et.Element(TAG_RESPONSE)
235 response = et.Element(TAG_RESPONSE)
236
236
237 status = et.SubElement(response, TAG_STATUS)
237 status = et.SubElement(response, TAG_STATUS)
@@ -8,7 +8,7 b" TAG_REQUEST = 'request'"
8 TAG_ID = 'id'
8 TAG_ID = 'id'
9
9
10 TYPE_GET = 'get'
10 TYPE_GET = 'get'
11 TYPE_PULL = 'pull'
11 TYPE_LIST = 'list'
12
12
13 ATTR_VERSION = 'version'
13 ATTR_VERSION = 'version'
14 ATTR_TYPE = 'type'
14 ATTR_TYPE = 'type'
@@ -39,13 +39,13 b' class GlobalIdManager(models.Manager):'
39
39
40 return et.tostring(request, 'unicode')
40 return et.tostring(request, 'unicode')
41
41
42 def generate_request_pull(self):
42 def generate_request_list(self):
43 """
43 """
44 Form a pull request from a list of ModelId objects.
44 Form a pull request from a list of ModelId objects.
45 """
45 """
46
46
47 request = et.Element(TAG_REQUEST)
47 request = et.Element(TAG_REQUEST)
48 request.set(ATTR_TYPE, TYPE_PULL)
48 request.set(ATTR_TYPE, TYPE_LIST)
49 request.set(ATTR_VERSION, '1.0')
49 request.set(ATTR_VERSION, '1.0')
50
50
51 model = et.SubElement(request, TAG_MODEL)
51 model = et.SubElement(request, TAG_MODEL)
@@ -1,5 +1,4 b''
1 from django.conf.urls import url
1 from django.conf.urls import url
2 #from django.views.i18n import javascript_catalog
3
2
4 import neboard
3 import neboard
5
4
@@ -9,10 +8,9 b' from boards.views import api, tag_thread'
9 settings, all_tags, feed
8 settings, all_tags, feed
10 from boards.views.authors import AuthorsView
9 from boards.views.authors import AuthorsView
11 from boards.views.notifications import NotificationView
10 from boards.views.notifications import NotificationView
12 from boards.views.search import BoardSearchView
13 from boards.views.static import StaticPageView
11 from boards.views.static import StaticPageView
14 from boards.views.preview import PostPreviewView
12 from boards.views.preview import PostPreviewView
15 from boards.views.sync import get_post_sync_data, response_get, response_pull
13 from boards.views.sync import get_post_sync_data, response_get, response_list
16 from boards.views.random import RandomImageView
14 from boards.views.random import RandomImageView
17 from boards.views.tag_gallery import TagGalleryView
15 from boards.views.tag_gallery import TagGalleryView
18 from boards.views.translation import cached_javascript_catalog
16 from boards.views.translation import cached_javascript_catalog
@@ -78,9 +76,8 b' urlpatterns = ['
78 url(r'^api/new_posts/$', api.api_get_new_posts, name='new_posts'),
76 url(r'^api/new_posts/$', api.api_get_new_posts, name='new_posts'),
79
77
80 # Sync protocol API
78 # Sync protocol API
81 url(r'^api/sync/pull/$', response_pull, name='api_sync_pull'),
79 url(r'^api/sync/list/$', response_list, name='api_sync_list'),
82 url(r'^api/sync/get/$', response_get, name='api_sync_pull'),
80 url(r'^api/sync/get/$', response_get, name='api_sync_get'),
83 # TODO 'get' request
84
81
85 # Notifications
82 # Notifications
86 url(r'^notifications/(?P<username>\w+)/$', NotificationView.as_view(), name='notifications'),
83 url(r'^notifications/(?P<username>\w+)/$', NotificationView.as_view(), name='notifications'),
@@ -6,13 +6,13 b' from boards.models import GlobalId, Post'
6 from boards.models.post.sync import SyncManager
6 from boards.models.post.sync import SyncManager
7
7
8
8
9 def response_pull(request):
9 def response_list(request):
10 request_xml = request.body
10 request_xml = request.body
11
11
12 if request_xml is None:
12 if request_xml is None or len(request_xml) == 0:
13 return HttpResponse(content='Use the API')
13 return HttpResponse(content='Use the API')
14
14
15 response_xml = SyncManager.generate_response_pull()
15 response_xml = SyncManager.generate_response_list()
16
16
17 return HttpResponse(content=response_xml)
17 return HttpResponse(content=response_xml)
18
18
@@ -25,7 +25,7 b' def response_get(request):'
25
25
26 request_xml = request.body
26 request_xml = request.body
27
27
28 if request_xml is None:
28 if request_xml is None or len(request_xml) == 0:
29 return HttpResponse(content='Use the API')
29 return HttpResponse(content='Use the API')
30
30
31 posts = []
31 posts = []
@@ -61,15 +61,15 b' responsible for validating it.'
61
61
62 The server is required to return the status of request. See 3.2 for details.
62 The server is required to return the status of request. See 3.2 for details.
63
63
64 ### 3.1.1 pull ###
64 ### 3.1.1 list ###
65
65
66 "pull" request gets the desired model id list by the given filter (e.g. thread, tags,
66 "list" request gets the desired model id list by the given filter (e.g. thread, tags,
67 author)
67 author)
68
68
69 Sample request is as follows:
69 Sample request is as follows:
70
70
71 <?xml version="1.1" encoding="UTF-8" ?>
71 <?xml version="1.1" encoding="UTF-8" ?>
72 <request version="1.0" type="pull">
72 <request version="1.0" type="list">
73 <model version="1.0" name="post">
73 <model version="1.0" name="post">
74 <timestamp_from>0</timestamp_from>
74 <timestamp_from>0</timestamp_from>
75 <timestamp_to>0</timestamp_to>
75 <timestamp_to>0</timestamp_to>
General Comments 0
You need to be logged in to leave comments. Login now