<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="wordpress/2.2.2" -->
<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/"
	>

<channel>
	<title>traviscline.com</title>
	<link>http://traviscline.com/blog</link>
	<description>/blog</description>
	<pubDate>Thu, 01 May 2008 17:12:03 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.2.2</generator>
	<language>en</language>
			<item>
		<title>generate a pdf with embedded vector art using reportlab and svglib</title>
		<link>http://traviscline.com/blog/2008/05/01/generate-a-pdf-with-embedded-vector-art-using-reportlab-and-svglib/</link>
		<comments>http://traviscline.com/blog/2008/05/01/generate-a-pdf-with-embedded-vector-art-using-reportlab-and-svglib/#comments</comments>
		<pubDate>Thu, 01 May 2008 16:56:14 +0000</pubDate>
		<dc:creator>tclineks</dc:creator>
		
		<category><![CDATA[python]]></category>

		<category><![CDATA[reportlab]]></category>

		<guid isPermaLink="false">http://traviscline.com/blog/2008/05/01/generate-a-pdf-with-embedded-vector-art-using-reportlab-and-svglib/</guid>
		<description><![CDATA[I was looking around for this and had a bit of trouble finding it, hopefully it will help out someone.
As far as I can tell getting vector artwork into reportlab in a sensible manner (i.e. aside from generating raw pdf commands) is practically restricted to using svg.
Dinu Gherman&#8217;s svglib is the tool to use.
Given tiger.svg, [...]]]></description>
			<content:encoded><![CDATA[<p>I was looking around for this and had a bit of trouble finding it, hopefully it will help out someone.</p>
<p>As far as I can tell getting vector artwork into reportlab in a sensible manner (i.e. aside from generating raw pdf commands) is practically restricted to using svg.</p>
<p><a href="http://python.net/~gherman/svglib.html">Dinu Gherman&#8217;s svglib</a> is the tool to use.</p>
<p>Given <a href="/examples/embed_svg_in_pdf/tiger.svg">tiger.svg</a>, <a href="http://python.net/~gherman/svglib.html">svglib</a> and:</p>

<div class="wp_syntax"><div class="code"><pre class="python"><span style="color: #ff7700;font-weight:bold;">from</span> reportlab.<span style="color: black;">pdfgen</span> <span style="color: #ff7700;font-weight:bold;">import</span> canvas
<span style="color: #ff7700;font-weight:bold;">from</span> reportlab.<span style="color: black;">lib</span>.<span style="color: black;">units</span> <span style="color: #ff7700;font-weight:bold;">import</span> cm
<span style="color: #ff7700;font-weight:bold;">from</span> svglib <span style="color: #ff7700;font-weight:bold;">import</span> svg2rlg, svg2pdfc = canvas.<span style="color: black;">Canvas</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;hello.pdf&quot;</span><span style="color: black;">&#41;</span>
&nbsp;
c.<span style="color: black;">drawString</span><span style="color: black;">&#40;</span><span style="color: #ff4500;">9</span>*cm, <span style="color: #ff4500;">22</span>*cm, <span style="color: #483d8b;">&quot;Hello World!&quot;</span><span style="color: black;">&#41;</span>
drawing = svg2rlg<span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;tiger.svg&quot;</span><span style="color: black;">&#41;</span>
drawing.<span style="color: black;">drawOn</span><span style="color: black;">&#40;</span>c, <span style="color: #ff4500;">200</span>, <span style="color: #ff4500;">200</span><span style="color: black;">&#41;</span>
&nbsp;
c.<span style="color: black;">showPage</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
c.<span style="color: black;">save</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span></pre></div></div>

<p><a href="/examples/embed_svg_in_pdf/embed_svg_in_pdf.py">(source) </a></p>
<p>You get: <a href="/examples/embed_svg_in_pdf/hello.pdf">hello.pdf</a></p>
<p>Apparently svglib only implements a subset of svg but should be usable in many circumstances.</p>
<p>Easy peasy.</p>
]]></content:encoded>
			<wfw:commentRss>http://traviscline.com/blog/2008/05/01/generate-a-pdf-with-embedded-vector-art-using-reportlab-and-svglib/feed/</wfw:commentRss>
		</item>
		<item>
		<title>komodo tab macro to ease django development</title>
		<link>http://traviscline.com/blog/2008/04/30/komodo-tab-macro-to-ease-django-development-in-komodo/</link>
		<comments>http://traviscline.com/blog/2008/04/30/komodo-tab-macro-to-ease-django-development-in-komodo/#comments</comments>
		<pubDate>Wed, 30 Apr 2008 16:13:49 +0000</pubDate>
		<dc:creator>tclineks</dc:creator>
		
		<category><![CDATA[Django]]></category>

		<category><![CDATA[Komodo]]></category>

		<guid isPermaLink="false">http://traviscline.com/blog/2008/04/30/komodo-tab-macro-to-ease-django-development-in-komodo/</guid>
		<description><![CDATA[One annoyance I came across while using komodo for django development was the barrage of 'models.py' and 'views.py' in editor tab titles.

I looked into what writing this macro would mean by going through the open komodo source only to arrive to the conclusion that it wasn't possible.  I started this thread on the activestate community forums:  <a href="http://community.activestate.com/forum-topic/tab-title-restriction-hurts-komodos-usability-django-projects">tab title restriction hurts Komodo's usability for Django projects</a>. <a href="http://blogs.activestate.com/shanec/">Shane Caraveo</a> came to the rescue and thankfully proved me wrong by posting a macro that sets tab titles.  Here's what I see now:

<img src="http://traviscline.com/blog/wp-content/uploads/2008/04/django_tab_titles.png" alt="django_tab_titles.png" />
]]></description>
			<content:encoded><![CDATA[<p>One annoyance I came across while using komodo for django development was the barrage of &#8216;models.py&#8217; and &#8216;views.py&#8217; in editor tab titles.</p>
<p>I looked into what writing this macro would mean by going through the open komodo source only to arrive to the conclusion that it wasn&#8217;t possible.  I started this thread on the activestate community forums:  <a href="http://community.activestate.com/forum-topic/tab-title-restriction-hurts-komodos-usability-django-projects">tab title restriction hurts Komodo&#8217;s usability for Django projects</a>. <a href="http://blogs.activestate.com/shanec/">Shane Caraveo</a> came to the rescue and thankfully proved me wrong by posting a macro that sets tab titles.  Here&#8217;s what I see now:</p>
<p><img src="http://traviscline.com/blog/wp-content/uploads/2008/04/django_tab_titles.png" alt="django_tab_titles.png" /></p>
<p>This macro is a slight extension of his work.  My version only shows the immediate parent directory and the current filename, not the entire path.  And I only modify the tab title for python files.</p>
<p>Even though some aspects of the api need further documentation this is a testament to Komodo&#8217;s extensibility.  While I like Komodo, I do think it could use better textmate-like snippet insertion (auto-completion of snippet names would be a good start).</p>
<p>Caveat: I&#8217;m guessing this doesn&#8217;t work on windows because of the slash.</p>
<p>Add an on startup trigger for it.<br />
<a href="http://dpaste.com/hold/47625/">http://dpaste.com/hold/47625/</a></p>
<pre language="javascript">try {
var vm = ko.views.manager.topView;
var box = document.getAnonymousNodes(vm)[0];

// get the views-tabbed elements
var tabset1 = box.firstChild;
var tabset2 = box.lastChild;

// replace the updateLeafName implementation to use something different
// for the tab label
tabset1.updateLeafName =
tabset2.updateLeafName = function(view) {
    view.parentNode._tab.label = view.title;
    if (view.document) {
        var language = view.document.language;
        if (language == 'Python') {
            var parts = view.document.displayPath.split('/');
            var len = parts.length;
            var label = '';
            if (len &gt; 2) {
                label += parts[len-2] + '/';
            }
            label += parts[len-1];

            view.parentNode._tab.setAttribute('crop', 'start');
            view.parentNode._tab.label = label;
            view.parentNode._tab.setAttribute('tooltiptext',view.document.displayPath);
            this.tabbox.firstChild.scrollBoxObject.ensureElementIsVisible(this.tabbox.firstChild.selectedItem);
        }
    }
};

// the "on startup" trigger happens after files
// are opened, so we need to call updateLeafName
// for each opened view.  Files opened after startup
// will be fine
var views = ko.views.manager.topView.getViews(true);
for (var i=0; i &lt; views.length; i++) {
    if (views[i].document) {
        views[i].updateLeafName(views[i]);
    }
}

} catch(e) {
    alert(e);
}</pre>
]]></content:encoded>
			<wfw:commentRss>http://traviscline.com/blog/2008/04/30/komodo-tab-macro-to-ease-django-development-in-komodo/feed/</wfw:commentRss>
		</item>
		<item>
		<title>quick_url - simple django filter to generate a url for a model instance</title>
		<link>http://traviscline.com/blog/2008/04/28/quick_url-simple-django-filter-to-generate-a-url-for-a-model-instance/</link>
		<comments>http://traviscline.com/blog/2008/04/28/quick_url-simple-django-filter-to-generate-a-url-for-a-model-instance/#comments</comments>
		<pubDate>Tue, 29 Apr 2008 04:48:13 +0000</pubDate>
		<dc:creator>tclineks</dc:creator>
		
		<category><![CDATA[Django]]></category>

		<guid isPermaLink="false">http://traviscline.com/blog/2008/04/28/quick_url-simple-django-filter-to-generate-a-url-for-a-model-instance/</guid>
		<description><![CDATA[This simple filter uses a model instance's get_absolute_url method and its string representation to make a url

<strong>{{ object&#124;quick_url }}</strong>
&#60;a href="/object/absolute/url"&#62;Object String Representation&#60;/a&#62;

Also posted on djangosnippets: <a href="http://www.djangosnippets.org/snippets/730/">http://www.djangosnippets.org/snippets/730/</a>]]></description>
			<content:encoded><![CDATA[<p>This simple filter uses a model instance&#8217;s get_absolute_url method and its string representation to make a url</p>
<p><strong>{{ object|quick_url }}</strong><br />
&lt;a href=&#8221;/object/absolute/url&#8221;&gt;Object String Representation&lt;/a&gt;</p>
<p>Also posted on djangosnippets: <a href="http://www.djangosnippets.org/snippets/730/">http://www.djangosnippets.org/snippets/730/</a></p>

<div class="wp_syntax"><div class="code"><pre class="python"><span style="color: #ff7700;font-weight:bold;">from</span> django <span style="color: #ff7700;font-weight:bold;">import</span> template
<span style="color: #ff7700;font-weight:bold;">from</span> django.<span style="color: black;">utils</span>.<span style="color: black;">html</span> <span style="color: #ff7700;font-weight:bold;">import</span> conditional_escape
<span style="color: #ff7700;font-weight:bold;">from</span> django.<span style="color: black;">utils</span>.<span style="color: black;">safestring</span> <span style="color: #ff7700;font-weight:bold;">import</span> mark_safe
register = template.<span style="color: black;">Library</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">def</span> quick_url<span style="color: black;">&#40;</span>addressable_object, autoescape=<span style="color: #008000;">None</span><span style="color: black;">&#41;</span>:
    <span style="color: #483d8b;">''</span><span style="color: #483d8b;">'filter to provide a url for a model instance'</span><span style="color: #483d8b;">''</span>
    <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #ff7700;font-weight:bold;">not</span> <span style="color: #008000;">hasattr</span><span style="color: black;">&#40;</span>addressable_object, <span style="color: #483d8b;">'get_absolute_url'</span><span style="color: black;">&#41;</span>:
        <span style="color: #ff7700;font-weight:bold;">return</span> addressable_object
    <span style="color: #ff7700;font-weight:bold;">if</span> autoescape:
        esc = conditional_escape
    <span style="color: #ff7700;font-weight:bold;">else</span>:
        esc = <span style="color: #ff7700;font-weight:bold;">lambda</span> x: x
    result = <span style="color: #483d8b;">'&lt;a href=&quot;%s&quot;&gt;%s&lt;/a&gt;'</span> % <span style="color: black;">&#40;</span>esc<span style="color: black;">&#40;</span>addressable_object.<span style="color: black;">get_absolute_url</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>, esc<span style="color: black;">&#40;</span>addressable_object<span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>
    <span style="color: #ff7700;font-weight:bold;">return</span> mark_safe<span style="color: black;">&#40;</span>result<span style="color: black;">&#41;</span>
quick_url.<span style="color: black;">needs_autoescape</span> = <span style="color: #008000;">True</span>
register.<span style="color: #008000;">filter</span><span style="color: black;">&#40;</span>quick_url<span style="color: black;">&#41;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://traviscline.com/blog/2008/04/28/quick_url-simple-django-filter-to-generate-a-url-for-a-model-instance/feed/</wfw:commentRss>
		</item>
		<item>
		<title>querysetrefactor merged into newforms-admin</title>
		<link>http://traviscline.com/blog/2008/04/28/querysetrefactor-merged-into-newforms-admin/</link>
		<comments>http://traviscline.com/blog/2008/04/28/querysetrefactor-merged-into-newforms-admin/#comments</comments>
		<pubDate>Mon, 28 Apr 2008 19:06:05 +0000</pubDate>
		<dc:creator>tclineks</dc:creator>
		
		<category><![CDATA[Django]]></category>

		<guid isPermaLink="false">http://traviscline.com/blog/2008/04/28/querysetrefactor-merged-into-newforms-admin/</guid>
		<description><![CDATA[I was just wondering if/when QuerySetRefactor was going to make it into newforms-admin.  Looks like Brian Rosner got the branch synched up to trunk in r7479 just two commits after the merge &#8212; there have been a few resynchs since, the most recent being r7500.
If I had listened to twid for 04-27 I would have [...]]]></description>
			<content:encoded><![CDATA[<p>I was just wondering if/when <a href="http://code.djangoproject.com/wiki/QuerysetRefactorBranch">QuerySetRefactor</a> was going to make it into <a href="http://code.djangoproject.com/wiki/NewformsAdminBranch">newforms-admin</a>.  Looks like Brian Rosner got the branch synched up to trunk in <a href="http://code.djangoproject.com/changeset/7479">r7479</a> just two commits after the merge &#8212; there have been a few resynchs since, the most recent being <a href="http://code.djangoproject.com/changeset/7500">r7500</a>.</p>
<p>If I had listened to <a href="http://blog.michaeltrier.com/2008/4/28/this-week-in-django-20-2008-04-27">twid</a> for 04-27 I would have known this sooner.</p>
]]></content:encoded>
			<wfw:commentRss>http://traviscline.com/blog/2008/04/28/querysetrefactor-merged-into-newforms-admin/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
