5 |
|
|
6 |
cvs_id = "$Id$" |
cvs_id = "$Id$" |
7 |
|
|
|
import urlparse |
|
|
import urllib |
|
|
import StringIO |
|
8 |
import straw |
import straw |
|
from error import log |
|
9 |
|
|
10 |
class Feed(object, straw.SignalEmitter): |
class Feed(object, straw.SignalEmitter): |
11 |
"A Feed object stores information set by user about a RSS feed." |
"A Feed object stores information set by user about a RSS feed." |
14 |
'_id', '_channel_description', |
'_id', '_channel_description', |
15 |
'_channel_title', '_channel_link', '_channel_copyright', |
'_channel_title', '_channel_link', '_channel_copyright', |
16 |
'channel_lbd', 'channel_editor', 'channel_webmaster', |
'channel_lbd', 'channel_editor', 'channel_webmaster', |
17 |
'_channel_subscriptions_location', '_channel_blogroll_location', |
'channel_creator', '_previous_etag', |
|
'_channel_subscriptions', '_channel_blogroll', |
|
|
'channel_blink', 'channel_creator', '_previous_etag', |
|
18 |
'_error', '_process_status', 'router', 'sticky') |
'_error', '_process_status', 'router', 'sticky') |
19 |
|
|
20 |
__save_fields = (('_title', ""), ('_location', ""), ('_username', ""), |
__save_fields = (('_title', ""), ('_location', ""), ('_username', ""), |
49 |
self.channel_editor = "" |
self.channel_editor = "" |
50 |
self.channel_webmaster = "" |
self.channel_webmaster = "" |
51 |
self.channel_creator = "" |
self.channel_creator = "" |
|
self._channel_subscriptions = "" |
|
|
self._channel_subscriptions_location = "" |
|
|
self._channel_blogroll = "" |
|
|
self._channel_blogroll_location = "" |
|
|
self.channel_blink = "" |
|
52 |
self._location = location |
self._location = location |
53 |
self._username = username |
self._username = username |
54 |
self._password = password |
self._password = password |
163 |
self.__setattr__(f, dict.get(f, default)) |
self.__setattr__(f, dict.get(f, default)) |
164 |
return |
return |
165 |
|
|
|
def complete_url(self, url): |
|
|
url = urllib.quote(url, safe="/,:?=&#") |
|
|
if urlparse.urlparse(url)[0] == '': |
|
|
return urlparse.urljoin(self._location, url) |
|
|
else: |
|
|
return url |
|
|
|
|
166 |
def poll_done(self): |
def poll_done(self): |
167 |
self.emit_signal(straw.FeedPolledSignal(self)) |
self.emit_signal(straw.FeedPolledSignal(self)) |
168 |
|
|
257 |
|
|
258 |
error = property(get_error, set_error, None, "") |
error = property(get_error, set_error, None, "") |
259 |
|
|
|
def get_channel_blogroll(self): |
|
|
return self._channel_blogroll |
|
|
|
|
|
def set_channel_blogroll(self, data): |
|
|
if data and len(data): |
|
|
try: |
|
|
self._channel_blogroll = straw.OPMLImport.read(StringIO.StringIO(data)) |
|
|
except Exception, ex: |
|
|
raise ex |
|
|
|
|
|
channel_blogroll = property(get_channel_blogroll, set_channel_blogroll, |
|
|
None, "") |
|
|
|
|
|
def get_channel_blogroll_location(self): |
|
|
return self._channel_blogroll_location |
|
|
|
|
|
def set_channel_blogroll_location(self, loc): |
|
|
self._channel_blogroll_location = loc |
|
|
|
|
|
channel_blogroll_location = property(get_channel_blogroll_location, |
|
|
set_channel_blogroll_location, None, "") |
|
|
|
|
|
def get_channel_subscriptions(self): |
|
|
return self._channel_subscriptions |
|
|
|
|
|
def set_channel_subscriptions(self, data): |
|
|
if data and len(data): |
|
|
try: |
|
|
self._channel_subscriptions = straw.OPMLImport.read(StringIO.StringIO(data)) |
|
|
except Exception, ex: |
|
|
raise ex |
|
|
|
|
|
channel_subscriptions = property(get_channel_subscriptions, |
|
|
set_channel_subscriptions, None, "") |
|
|
|
|
|
|
|
|
def get_channel_subscriptions_location(self): |
|
|
return self._channel_subscriptions_location |
|
|
|
|
|
def set_channel_subscriptions_location(self, loc): |
|
|
self._channel_subscriptions_location = loc |
|
|
|
|
|
channel_subscriptions_location = property(get_channel_subscriptions_location, |
|
|
set_channel_subscriptions_location, None, "") |
|
|
|
|
|
|
|
260 |
def set_process_status(self, status): |
def set_process_status(self, status): |
261 |
if status != self._process_status: |
if status != self._process_status: |
262 |
self._process_status = status |
self._process_status = status |