I'm working on a project that reads feeds from tumblr.com and displays
on my page. The api is a simple xml file (http://beertje.tumblr.com/
api/read/), which I process with BeautifulSoup.

Here's a sample tumblr post:

<post id="24484315" url="http://beertje.tumblr.com/post/24484315";
type="quote" date="Wed, 23 Jan 2008 16:32:04"
bookmarklet="true"><quote-text>We called him Tortoise because he
taught us.</quote-text><quote-source>&lt;a href="http://www.crummy.com/
software/BeautifulSoup/"&gt;http://www.crummy.com/software/
BeautifulSoup/&lt;/a&gt;&lt;br style="text-decoration: underline"/
&gt;</quote-source></post>

As you see, the html in <quote-source> is escaped, and so when I print
it out in a template it shows up as HTML code, rather than a nice
link.

I'm using 0.96.1 so the safe filter doesn't (seem to) work, so I'm not
entirely sure about how I should do this. Any tips?

Thanks,
-Björn

P.S. Here's what sets up my models, one for each content type on
tumblr (Quote, Regular, Photo...):

def process_tumbl(post, user, model):
    id = post['id']
    pubdate = datetime(*strptime(post['date'], "%a, %d %b %Y %H:%M:%S")
[0:7])
    if post['type'] == "quote":
        quote = post.find('quote-text').contents[0]
        if post.find('quote-source'):
            source = post.find('quote-source').contents[0]
        else:
            source = ""
        r = model(id=id, pubdate=pubdate, user=user, quote=quote,
source=source)

Is there a cleaner way of doing this? quote-source is optional, seems
a bit amateurish to set it as ""... :P
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to