예제 #1
0
def _handle_status(message_text, url, timestamp):
    message_text, links, tags = _parse_message(message_text)

    t = Message(
        message = message_text,
        )

    if not _status_exists(message_text, url, timestamp):
        log.debug("Saving message: %r", message_text)
        item = Item.objects.create_or_update(
            instance = t,
            timestamp = timestamp,
            source = __name__,
            source_id = _source_id(message_text, url, timestamp),
            url = url,
            tags = tags,
            )
        item.save()

        for link in links:
            l = ContentLink(
                url = link,
                identifier = link,
                )
            l.save()
            t.links.add(l)
    def forwards(self, orm):
        "Write your forwards methods here."
        for s in orm.Status.objects.all().order_by('date_published'):
            existing_item = Item.objects.get(content_type=37, object_id=s.id)
            if int(existing_item.source_id) < 1046567017:
                message_text, links, tags = _parse_message(s.body)
                t = Message(message = message_text)
               
                new_item = Item.objects.create_or_update(
                   instance = t,
                   timestamp = existing_item.timestamp,
                   source = "jellyroll.providers.twitter",
                   source_id = existing_item.source_id,
                   url = "http://twitter.com/brianmckinney/statuses/%s" % existing_item.source_id,
                   tags = tags,
                )
                new_item.save()

                for link in links:
                     l = ContentLink(
                        url = link,
                        identifier = link,
                        )
                     l.save()
                     t.links.add(l)
예제 #3
0
def _handle_status(message_text, url, timestamp):
    message_text, links, tags = _parse_message(message_text)

    t = Message(message=message_text, )

    if not _status_exists(message_text, url, timestamp):
        log.debug("Saving message: %r", message_text)
        item = Item.objects.create_or_update(
            instance=t,
            timestamp=timestamp,
            source=__name__,
            source_id=_source_id(message_text, url, timestamp),
            url=url,
            tags=tags,
        )
        item.save()

        for link in links:
            l = ContentLink(
                url=link,
                identifier=link,
            )
            l.save()
            t.links.add(l)