def _new_user_item(user, feed, entry): try: item = FeedItem.objects.get(reader_guid=entry.id) except ObjectDoesNotExist: tmp = FeedItem() tmp.feed = feed tmp.title = entry.title tmp.link = entry.url tmp.atom_id = '' tmp.description = entry.content tmp.reader_guid = entry.id tmp.published = datetime.utcfromtimestamp(entry.time) tmp.guid = tmp.calculate_guid() item = FeedItem._get_or_create(tmp) try: user_item = item.userfeeditem(user) except ObjectDoesNotExist: # Nasty. The above only works if a user is actually # subscribed to a feed. However, it can be the case # where we're trying to import Google Reader, and we're # processing items that have been shared with us. In # this case, we probably won't be subscribed to the # feed, and more, we probably don't want to subscribe to # the feed. So manually create a UserFeedItem so the # Item can be accessed by the User. We can pull it out # of the db later by searching for the 'shared-with-you' # tag. user_item = UserFeedItem() user_item.item = item user_item.user = user user_item.feed = feed user_item.save() user_item.read = entry.read user_item.starred = entry.starred for t in entry.tags: user_item.tags.add(t) user_item.save() return user_item