Beispiel #1
0
 def _import_post(self, item):
     '''Creates a new Entry object from a post and saves it.'''
     wp_ns = self.wp_ns
     content_ns = self.content_ns
     if item.find(wp_ns + 'post_type').text == 'post':
         post = Post()
         post.author = self.get_author()
         post.title = item.find('title').text
         if not post.title:
             post.title = 'ab origine' # Latin for 'from the source'
         post.content = item.find(content_ns + 'encoded').text
         if post.content:
             post.content = post.content.replace("\n", "<br />")
         post.teaser = item.find(self.excerpt_ns + 'encoded').text
         # Parse wp:post_date in format 2002-02-27 13:39:00
         postdate = datetime.strptime(item.find(wp_ns + 'post_date').text, "%Y-%m-%d %H:%M:%S")
         post.pub_date = postdate
         status = item.find(wp_ns + 'status').text
         if status == 'publish':
             post.status = 'P'
         else:
             post.status = 'U'
         try: 
             post.save()
             
             # modify date_created after save because autonow is on.
             post.date_created = postdate
             post.save()
             # Enrich the rest of the post.
             self._post_meta(post, item)
             self._catalog_post(post, item)
 
         except:
             sys.stderr.write("Error importing %s" % post.title)
             pass
Beispiel #2
0
    def _import_post(self, item):
        '''Creates a new Entry object from a post and saves it.'''
        wp_ns = self.wp_ns
        content_ns = self.content_ns

        if item.find(wp_ns + 'post_type').text == 'post':
            # These methods are only for scrubbing my crappy content.
            # @TODO remove after I run on my blog.
            item_title = item.find('title').text
            item_content = item.find(content_ns + 'encoded').text
            if item_title and re.search('From Twitter ', item_title):
                print "Skipping tittinisis post %s" % item_title
                return True
            # @TODO remove after I run on my blog.
            if item_content and re.search('LoudTwitter', item_content):
                print "Skipping loudtwitter post %s" % item.find('title').text
                return True
            post = Post()
            post.author = self.get_author()
            post.title = item_title
            if post.title and len(post.title) > 75:
                post.title = post.title[:75]
            if not post.title:
                post.title = 'ab origine'  # Latin for 'from the source'
            post.content = item_content
            if post.content:
                post.content = post.content.replace("\n", "<br />")
            excerpt = item.find(self.excerpt_ns + 'encoded')
            if excerpt:
                post.teaser = excerpt.text
            # Parse wp:post_date in format 2002-02-27 13:39:00
            postdate = datetime.strptime(
                item.find(wp_ns + 'post_date').text, "%Y-%m-%d %H:%M:%S")
            post.pub_date = postdate
            status = item.find(wp_ns + 'status').text
            if status == 'publish':
                post.status = 'P'
            else:
                post.status = 'U'
            #try:
            post.save()

            # modify date_created after save because autonow is on.
            post.date_created = postdate
            post.save()
            # Enrich the rest of the post.
            self._post_meta(post, item)
            self._catalog_post(post, item)
Beispiel #3
0
    def _import_post(self, item):
        '''Creates a new Entry object from a post and saves it.'''
        wp_ns = self.wp_ns
        content_ns = self.content_ns

        if item.find(wp_ns + 'post_type').text == 'post':
            # These methods are only for scrubbing my crappy content.
            # @TODO remove after I run on my blog.
            item_title = item.find('title').text
            item_content = item.find(content_ns + 'encoded').text
            if item_title and re.search('From Twitter ', item_title):
                print "Skipping tittinisis post %s" % item_title
                return True
            # @TODO remove after I run on my blog.
            if item_content and re.search('LoudTwitter', item_content):
                print "Skipping loudtwitter post %s" % item.find('title').text
                return True
            post = Post()
            post.author = self.get_author()
            post.title = item_title
            if post.title and len(post.title) > 75:
                post.title = post.title[:75]
            if not post.title:
                post.title = 'ab origine' # Latin for 'from the source'
            post.content = item_content
            if post.content:
                post.content = post.content.replace("\n", "<br />")
            excerpt = item.find(self.excerpt_ns + 'encoded')
            if excerpt:
                post.teaser = excerpt.text
            # Parse wp:post_date in format 2002-02-27 13:39:00
            postdate = datetime.strptime(item.find(wp_ns + 'post_date').text, "%Y-%m-%d %H:%M:%S")
            post.pub_date = postdate
            status = item.find(wp_ns + 'status').text
            if status == 'publish':
                post.status = 'P'
            else:
                post.status = 'U'
            #try:
            post.save()

            # modify date_created after save because autonow is on.
            post.date_created = postdate
            post.save()
            # Enrich the rest of the post.
            self._post_meta(post, item)
            self._catalog_post(post, item)