<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Intrepid Blog &#187; html</title>
	<atom:link href="http://blog.affien.com/archives/tag/html/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.affien.com</link>
	<description>A few thoughts</description>
	<lastBuildDate>Mon, 23 Jan 2012 08:47:37 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Python Html Document Abstraction</title>
		<link>http://blog.affien.com/archives/2005/03/06/python-html-document-abstraction/</link>
		<comments>http://blog.affien.com/archives/2005/03/06/python-html-document-abstraction/#comments</comments>
		<pubDate>Sun, 06 Mar 2005 18:15:58 +0000</pubDate>
		<dc:creator>Bas Westerbaan</dc:creator>
				<category><![CDATA[Web development]]></category>
		<category><![CDATA[dynamic]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://blog.w-nz.com/archives/2005/03/06/python-html-document-abstraction/</guid>
		<description><![CDATA[Python is great!

>>> d = document()
>>> d.html.body [...]]]></description>
			<content:encoded><![CDATA[<p>Python is great!</p>
<blockquote><pre style="font-size: 12px">>>> d = document()
>>> d.html.body.h1.value = "My Site!"
>>> d.html.body.p.value = "Welcome to this python generated site"
>>> str(d)
'&lt;?xml version="1.0" encoding="UTF-8"?&gt;&lt; !DOCTYPE html PUBLIC "-//W3C//DTD XHTML
 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"&gt;
&lt;html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"&gt;
&lt;body&gt;&lt;p&gt;Welcome to this python generated site&lt;/p&gt;
&lt;h1&gt;My site!&lt;/h1&gt;&lt;/body&gt;&lt;head&gt;&lt;title&gt;
&lt;/title&gt;&lt;/head>&lt;/html&gt;'
</pre>
</blockquote>
<p>(<em>Ignore the added slashes and the additional line breaks caused by wordpress</em>)</p>
<p>By overloading the <code>__get</code>/<code>set</code>/<code>delattr__</code> functions a html document can be represented like a real python object model. </p>
<p>I&#8217;ve just experimented a little bit with python code to ultimately go to write a framework to write nice dynamic python webbased applications in.</p>
<p>Although it appears that the names of the objects (<code>html</code>, <code>body</code>, <code>p</code>, etc) are the tag names, they aren&#8217;t. They are the identifiers of the tags.. in case the tag isn&#8217;t set by yourself but just created for it didn&#8217;t existed it uses as tag its alleged id.</p>
<p>The default created object when no object exists already with that id is a <code>tag</code>. This abstract document won&#8217;t be limited to tags. I&#8217;ve just made a <code>styleTag</code> class which allows:</p>
<blockquote><pre style="font-size: 12px">d.html.head.style.body["font-family"] = 'verdana'</pre>
</blockquote>
<p>which is basicly the same as</p>
<blockquote><pre style="font-size: 12px">d.html.head.style.["body"].font-family = 'verdana'</pre>
</blockquote>
<p>In contrary to the normal <code>tag</code> class where an <em>item</em> is an attribute, this is different in the style tag for CSS got a lot of characters which python doesn&#8217;t like (like #).</p>
<p>Being able to manipulate a style sheet that easily allows every custom tag (maybe a <code>datetimepickercontrol</code>) to set its own style information by just using simple python code.</p>
<p>For the <code>styletag</code> isn&#8217;t bound to putting its emitted css in the emitted-html string itself in case it is emit-ed in a specific context like a webserver, it can even create a seperate css for this purpose.</p>
<p>Python allows much more dynamic features in a dynamic framework like this than any other language, I`m quite enthousiastic about it and am playing with new idea&#8217;s like a little child <img src='http://blog.affien.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> .</p>
<p>All kinds of idea&#8217;s would be welcome..</p>
<p>Just wondering whether such a thing has already been written for Python.. anyone knows?</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.affien.com/archives/2005/03/06/python-html-document-abstraction/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

