Mercurial > libervia-web
comparison src/server/blog.py @ 481:bbdc5357dc00
browser and server sides: refactor HTTP request result values + handle "NoReply" error
author | souliane <souliane@mailoo.org> |
---|---|
date | Sun, 15 Jun 2014 17:52:08 +0200 |
parents | 3ef6ce200c27 |
children | 0bbbef1d53a8 |
comparison
equal
deleted
inserted
replaced
480:50b286866739 | 481:bbdc5357dc00 |
---|---|
57 'message': "You must indicate a nickname"} | 57 'message': "You must indicate a nickname"} |
58 else: | 58 else: |
59 prof_requested = request.postpath[0] | 59 prof_requested = request.postpath[0] |
60 #TODO: char check: only use alphanumerical chars + some extra(_,-,...) here | 60 #TODO: char check: only use alphanumerical chars + some extra(_,-,...) here |
61 prof_found = self.host.bridge.getProfileName(prof_requested) | 61 prof_found = self.host.bridge.getProfileName(prof_requested) |
62 if not prof_found or prof_found == 'libervia': | 62 if not prof_found or prof_found == C.SERVICE_PROFILE: |
63 return MicroBlog.ERROR_TEMPLATE % {'root': '../' * len(request.postpath), | 63 return MicroBlog.ERROR_TEMPLATE % {'root': '../' * len(request.postpath), |
64 'message': "Invalid nickname"} | 64 'message': "Invalid nickname"} |
65 else: | 65 else: |
66 def got_jid(pub_jid_s): | 66 def got_jid(pub_jid_s): |
67 pub_jid = JID(pub_jid_s) | 67 pub_jid = JID(pub_jid_s) |
72 except (ValueError, KeyError): | 72 except (ValueError, KeyError): |
73 max_items = 10 | 73 max_items = 10 |
74 if len(request.postpath) > 1: | 74 if len(request.postpath) > 1: |
75 if request.postpath[1] == 'atom.xml': # return the atom feed | 75 if request.postpath[1] == 'atom.xml': # return the atom feed |
76 d2.addCallbacks(self.render_atom_feed, self.render_error_blog, [request], None, [request, prof_found], None) | 76 d2.addCallbacks(self.render_atom_feed, self.render_error_blog, [request], None, [request, prof_found], None) |
77 self.host.bridge.getLastGroupBlogsAtom(pub_jid.userhost(), max_items, 'libervia', d2.callback, d2.errback) | 77 self.host.bridge.getLastGroupBlogsAtom(pub_jid.userhost(), max_items, C.SERVICE_PROFILE, d2.callback, d2.errback) |
78 return | 78 return |
79 try: # check if the given path is a valid UUID | 79 try: # check if the given path is a valid UUID |
80 uuid.UUID(request.postpath[1]) | 80 uuid.UUID(request.postpath[1]) |
81 item_id = request.postpath[1] | 81 item_id = request.postpath[1] |
82 except ValueError: | 82 except ValueError: |
83 pass | 83 pass |
84 d2.addCallbacks(self.render_html_blog, self.render_error_blog, [request, prof_found], None, [request, prof_found], None) | 84 d2.addCallbacks(self.render_html_blog, self.render_error_blog, [request, prof_found], None, [request, prof_found], None) |
85 if item_id: # display one message and its comments | 85 if item_id: # display one message and its comments |
86 self.host.bridge.getGroupBlogsWithComments(pub_jid.userhost(), [item_id], 'libervia', d2.callback, d2.errback) | 86 self.host.bridge.getGroupBlogsWithComments(pub_jid.userhost(), [item_id], C.SERVICE_PROFILE, d2.callback, d2.errback) |
87 else: # display the last messages without comment | 87 else: # display the last messages without comment |
88 self.host.bridge.getLastGroupBlogs(pub_jid.userhost(), max_items, 'libervia', d2.callback, d2.errback) | 88 self.host.bridge.getLastGroupBlogs(pub_jid.userhost(), max_items, C.SERVICE_PROFILE, d2.callback, d2.errback) |
89 | 89 |
90 d1 = defer.Deferred() | 90 d1 = defer.Deferred() |
91 JID(self.host.bridge.asyncGetParamA('JabberID', 'Connection', 'value', C.SERVER_SECURITY_LIMIT, prof_found, callback=d1.callback, errback=d1.errback)) | 91 JID(self.host.bridge.asyncGetParamA('JabberID', 'Connection', 'value', C.SERVER_SECURITY_LIMIT, prof_found, callback=d1.callback, errback=d1.errback)) |
92 d1.addCallbacks(got_jid) | 92 d1.addCallbacks(got_jid) |
93 | 93 |