hupili / snsapi

Cross platform middleware for Social Networking Services: Twitter, Facebook, SinaWeibo, Renren, RSS, Email, Sqlite, ... (more coming)
http://snsapi.ie.cuhk.edu.hk
159 stars 53 forks source link

Support Parameterized Message Parsing #75

Closed hupili closed 11 years ago

hupili commented 11 years ago

Current way of Message parsing:

Here is a use case where the above way is not enough. RSS feeds are too heterogeneous. Some of the feeds do not include timezone suffix. In order to parse a correct time, we must add this suffix according to user's knowledge. In current implementation, platform class and message class are isolated. There is no way to pass this information.

hupili commented 11 years ago

A sample channel.json:

[
  {
    "url": "http://www.people.com.cn/rss/politics.xml", 
    "platform": "RSSSummary", 
    "__other__info": {
      "text": "\u56fd\u5185\u65b0\u95fb", 
      "html_url": "http://politics.people.com.cn"
    }, 
    "open": "yes", 
    "channel_name": "ch21. \u56fd\u5185\u65b0\u95fb",
    "message":{
      "timezone_correction": " +08:00"
    }
  }
]

The message dict will be passed to Message class. parse can refer to the message parsing parameters in self.conf or ignore it. This way is backward compatible.

hupili commented 11 years ago

Note one failed trial:

This method is potentially more resource preserving. One data field is saved. One parameter passing is saved on each construction call of Message.

There are two difficulties:

Anyway, I would return to the plain implementation. The overhead incurred by this upgrade should be acceptable.