FearAndLoath.Us

Fear Computers. Loath Software. We are your Masters.

Sunday, February 24, 2008

Too cool for school

I gotta get some of these jeans.


posted by admin at 9:47 pm  

Sunday, February 3, 2008

IE7 gotchas & workarounds

Despite articles such as “Preparing your feeds for IE7″, there are still unforseen problems getting IE7 to handle Atom or RSS feeds. Before getting into these problems, I want to point out two incredibly useful tools for testing IE7 when you don’t have access to Windows. browsershots.org lets you get a screenshot of IE7 or most any browser for free, although there is a 30 minute delay. For professionals who need to test rendering in many different browsers, browsercam.com is definitely valuable. However, if you just need to test IE7 without a 30 minute delay like browsershots.org, then running Windows under VMWare would be more economical than a year’s subscription to browsercam.com.

Problem #1: IE7 is cranky about <style> tags in the <body>

It is against standards to put a <style> tag in the <body> of your document, but IE7 doesn’t support the <head> tag in an Atom/RSS feed. It wouldn’t be that bad if it just ignored the css in the <style> tag, but it actually displays it in the page.

Problem #2: Displaying HTML entities in an Atom/RSS feed

Since IE7 won’t process a feed with a DTD, you can’t use HTML entities such as “ ” in your xhtml because xml only knows about five entities until a DTD defines them. There are three solutions to this problem.

  1. In your Atom feed, use <content type=”html”> instead of <content type=”xhtml”>. Ths is the easiest solution, and it just requires that you escape “<”, “>”, and “&”. The only downside is that debugging display errors by viewing the source is more difficult, since “<b>” will look like “<b>”.
  2. You can convert the entites into UTF-8. This python code for achieving this is:
    decodedString = unicode(BeautifulSoup(encodedString,convertEntities=BeautifulSoup.HTML_ENTITIES ))
    utf8_string = decodedString.encode('utf-8')
  3. You can convert the named entities into numerical entities, i.e. “ ” becomes “ ”. The python code for achieving this is very similar:
    decodedString = unicode(BeautifulSoup(encodedString,convertEntities=BeautifulSoup.HTML_ENTITIES ))
    ascii_string = decodedString.encode('ascii', 'xmlcharrefreplace')

Even though BeautifulSoup (used above) is intended for HTML, and BeautifulStoneSoup is for XML, BeautifulSoup works better in this situation because you don’t have to worry about this issue with nested tags.

posted by admin at 7:29 pm  

Sunday, February 3, 2008

Cleaner setters for attributes in python

Using a method for a read-only object attribute is very clean in python.

class foo:
    @property
    def name(self):
        return self._name

However, providing a setter method is somewhat ugly. Someone came up with an interesting workaround.

posted by admin at 5:01 pm  

Sunday, February 3, 2008

Ubuntu is on the rise

According to this CNET blog, more customers for Alfresco CMS are interested in deploying on Ubuntu than RHEL.

posted by admin at 4:56 pm  

Powered by WordPress