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