Mercurial > libervia-web
comparison libervia.tac @ 132:30d8e328559b
server & browser side: microblogging refactoring first draft
- use of new getLastGroupBlogs and getMassiveLastGroupBlogs methods
- microblgos browser's cache is temporarily deactivated
- last 10 microblogs for everybody are requested on new meta microblog widget
author | Goffi <goffi@goffi.org> |
---|---|
date | Mon, 02 Apr 2012 00:25:38 +0200 |
parents | ddfcc4cb6cee |
children | 4ad621df9e34 |
comparison
equal
deleted
inserted
replaced
131:ddfcc4cb6cee | 132:30d8e328559b |
---|---|
199 if recip == '@' and text: | 199 if recip == '@' and text: |
200 #This text if for the public microblog | 200 #This text if for the public microblog |
201 return self.sat_host.bridge.sendPersonalEvent("MICROBLOG", {'content':text}, profile) | 201 return self.sat_host.bridge.sendPersonalEvent("MICROBLOG", {'content':text}, profile) |
202 else: | 202 else: |
203 return self.sat_host.bridge.sendGroupBlog([recip], text, profile) | 203 return self.sat_host.bridge.sendGroupBlog([recip], text, profile) |
204 | |
205 def jsonrpc_getLastMblogs(self, publisher_jid, max_item): | |
206 """Get last microblogs posted by a contact | |
207 @param publisher_jid: jid of the publisher | |
208 @param max_item: number of items to ask | |
209 @return list of microblog data (dict)""" | |
210 profile = ISATSession(self.session).profile | |
211 d = defer.Deferred() | |
212 self.sat_host.bridge.getLastGroupBlogs(publisher_jid, max_item, profile, callback=d.callback, errback=d.errback) | |
213 return d | |
214 | |
215 def jsonrpc_getMassiveLastMblogs(self, publishers_type, publishers_list, max_item): | |
216 """Get lasts microblogs posted by several contacts at once | |
217 @param publishers_type: one of "ALL", "GROUP", "JID" | |
218 @param publishers_list: list of publishers type (empty list of all, list of groups or list of jids) | |
219 @param max_item: number of items to ask | |
220 @return: dictionary key=publisher's jid, value=list of microblog data (dict)""" | |
221 profile = ISATSession(self.session).profile | |
222 d = defer.Deferred() | |
223 self.sat_host.bridge.getMassiveLastGroupBlogs(publishers_type, publishers_list, max_item, profile, callback=d.callback, errback=d.errback) | |
224 return d | |
204 | 225 |
205 def jsonrpc_getPresenceStatus(self): | 226 def jsonrpc_getPresenceStatus(self): |
206 """Get Presence information for connected contacts""" | 227 """Get Presence information for connected contacts""" |
207 profile = ISATSession(self.session).profile | 228 profile = ISATSession(self.session).profile |
208 return self.sat_host.bridge.getPresenceStatus(profile) | 229 return self.sat_host.bridge.getPresenceStatus(profile) |
298 """Tell if a profile is trying to log in""" | 319 """Tell if a profile is trying to log in""" |
299 if self.profiles_waiting.has_key(profile): | 320 if self.profiles_waiting.has_key(profile): |
300 return self.profiles_waiting[profile] | 321 return self.profiles_waiting[profile] |
301 else: | 322 else: |
302 return None | 323 return None |
303 | |
304 def _fillMblogNodes(self, result, session): | |
305 """Fill the microblog nodes association for this session""" | |
306 session.sat_mblog_nodes = dict(result) | |
307 | 324 |
308 def render(self, request): | 325 def render(self, request): |
309 """ | 326 """ |
310 Render method with some hacks: | 327 Render method with some hacks: |
311 - if login is requested, try to login with form data | 328 - if login is requested, try to login with form data |
512 self.sat_host.bridge.disconnect(profile) | 529 self.sat_host.bridge.disconnect(profile) |
513 | 530 |
514 _session.notifyOnExpire(onExpire) | 531 _session.notifyOnExpire(onExpire) |
515 | 532 |
516 d = defer.Deferred() | 533 d = defer.Deferred() |
517 self.sat_host.bridge.getMblogNodes(profile, d.callback, d.errback) | |
518 d.addCallback(self._fillMblogNodes, _session) | |
519 return result('LOGGED') | 534 return result('LOGGED') |
520 | 535 |
521 def _logginError(self, login, request, error_type): | 536 def _logginError(self, login, request, error_type): |
522 """Something went wrong during loggin, return an error""" | 537 """Something went wrong during loggin, return an error""" |
523 self.__cleanWaiting(login) | 538 self.__cleanWaiting(login) |