Example #1
0
    def from_data(cls, id, login, url, fetch=False, **kwargs):
        self = cls(None, None)
        self.id = id
        self.login = login

        if url and not parse_url(url):
            raise InvalidFeedUrl
        self._url = url

        if 'info' in kwargs:
            self.info = kwargs['info']

        #if not self.id and self._url:
        #    key = "feed_info:%s" % self._url
        #    try:
        #        raise TypeError
        #        info, entries = cache_get(key)
        #
        #        for i in info:
        #            self.set_info(i, info[i])
        #
        #        self._entries = entries
        #
        #    except TypeError:
        if fetch:
            self.fetch()

        return self
Example #2
0
    def from_data(cls, id, login, url, fetch=False, **kwargs):
        self = cls(None, None)
        self.id = id
        self.login = login

        if url and not parse_url(url):
            raise InvalidFeedUrl
        self._url = url

        if 'info' in kwargs:
            self.info = kwargs['info']

        #if not self.id and self._url:
        #    key = "feed_info:%s" % self._url
        #    try:
        #        raise TypeError
        #        info, entries = cache_get(key)
        #
        #        for i in info:
        #            self.set_info(i, info[i])
        #
        #        self._entries = entries
        #
        #    except TypeError:
        if fetch:
            self.fetch()

        return self
Example #3
0
    def __init__(self, field, value=None):
        self._url = None

        if field == 'url':
            self._url = value
        elif isinstance(field, (str, unicode)):
            if field.startswith('http://') or field.startswith('https://'):
                self._url = field
            elif not value:
                raise InvalidFeedUrl

        if self._url:
            if not parse_url(self._url, exact=True):
                raise InvalidFeedUrl

            key = 'url_feed_id:%s' % self._url

            id = cache_get(key)
            if not id:
                res = db.fetchone("SELECT id FROM users.feeds WHERE url=%s;",
                                  [self._url])
                if res:
                    id = res['id']
                    cache_store(key, id)

            if not id:
                raise FeedNotFound

            try:
                User.__init__(self, long(id))
            except UserNotFound:
                raise FeedNotFound
        else:
            try:
                User.__init__(self, field, value)
            except UserNotFound:
                raise FeedNotFound

        self._posts = []
Example #4
0
    def __init__(self, field, value=None):
        self._url = None

        if field == 'url':
            self._url = value
        elif isinstance(field, (str, unicode)):
            if field.startswith('http://') or field.startswith('https://'):
                self._url = field
            elif not value:
                raise InvalidFeedUrl

        if self._url:
            if not parse_url(self._url, exact=True):
                raise InvalidFeedUrl

            key = 'url_feed_id:%s' % self._url

            id = cache_get(key)
            if not id:
                res = db.fetchone("SELECT id FROM users.feeds WHERE url=%s;",
                                  [self._url])
                if res:
                    id = res['id']
                    cache_store(key, id)

            if not id:
                raise FeedNotFound

            try:
                User.__init__(self, long(id))
            except UserNotFound:
                raise FeedNotFound
        else:
            try:
                User.__init__(self, field, value)
            except UserNotFound:
                raise FeedNotFound

        self._posts = []