<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-455416252368984615</id><updated>2011-11-27T15:45:11.425-08:00</updated><category term='tricks projects'/><category term='Basics'/><category term='django'/><category term='Systems'/><title type='text'>HappyPython</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://happypython.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/455416252368984615/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://happypython.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Matt Franz</name><uri>http://www.blogger.com/profile/00973881935128108475</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_MPIoEEC-IC0/SWXZy3zT_TI/AAAAAAAABHY/FmMm-co3m0Y/S220/blah.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>23</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-455416252368984615.post-2008420148976627895</id><published>2009-11-28T13:11:00.001-08:00</published><updated>2009-11-28T13:11:31.692-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='django'/><title type='text'>Generating SVG Output (from Graphviz) in your Django App</title><content type='html'>So accomplishing new coding tasks can be a challenge with interruptions and I've had a lot of interruptions this week but I finally got there. And I'm thankful!&lt;br /&gt;&lt;br /&gt;I have an app that is storing data, meaning Django models for the uninitiated. What is in there doesn't matter, but it is something that is conducive to plotting with &lt;a href="http://graphviz.org/"&gt;graphviz&lt;/a&gt;. So the starting point is a string that is in the &lt;a href="http://graphviz.org/Gallery/directed/unix.gv.txt"&gt;.dot format&lt;/a&gt;. I have some code that makes queries to the database and I end up with a string.&lt;br /&gt;&lt;br /&gt;So there is a utility function that creates this string...&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;def make_svg_str:&lt;br /&gt;#blah blah blah snip&lt;br /&gt;dot_string += "}"&lt;br /&gt;p = subprocess.Popen('/usr/bin/dot -Tsvg', shell=True,\&lt;br /&gt;stdin=subprocess.PIPE, stdout=subprocess.PIPE)&lt;br /&gt;(stdout,stderr) = p.communicate(dot_string)&lt;br /&gt;return stdout&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;So I &lt;i&gt;almost&lt;/i&gt; got this right the first time except that I forgot the stdout in Popen() which caused the output to go to stdout (and not be assigned to the string) so I saw the .xml in the dev web server logs.&lt;br /&gt;&lt;br /&gt;The graphviz string (dot_string) is being piped to the dot executable and then the function is returning the XML SVG as a string, and is obviously assigned to the stdout variable in the tuple.&lt;br /&gt;&lt;br /&gt;Now the tricky part within my views.py.&lt;br /&gt;&lt;br /&gt;My first mistake was using the &lt;a href="http://docs.djangoproject.com/en/dev/howto/outputting-csv/"&gt;Django CSV&lt;/a&gt; docs instead of the &lt;a href="http://docs.djangoproject.com/en/dev/howto/outputting-pdf/#howto-outputting-pdf"&gt;PDF docs&lt;/a&gt; because the latter is what we need. I also didn't remember that HttpResponse is a file-like object so we can can just write to it once we have the SVG text.&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;def svg(request):&lt;br /&gt;f = Foo.objects.all()&lt;br /&gt;response = HttpResponse(mimetype='image/svg+xml')&lt;br /&gt;response['Content-Disposition'] = 'filename=somefilename.svg'&lt;br /&gt;response.write(make_svg_str(f))&lt;br /&gt;return response&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;So this will display your image within your browser (which is what I wanted) instead of downloading file if you the use the "attachment" in the Content-Disposition key.&lt;br /&gt;&lt;br /&gt;The name of the game is taking shortcuts that get the job done. I'm using the admin interface to provide a good-enough UI to enter the data and now I'm using Graphviz to visualize that data without having to spend a lot of time writing UIs or nasty JavaScript.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/455416252368984615-2008420148976627895?l=happypython.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://happypython.blogspot.com/feeds/2008420148976627895/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=455416252368984615&amp;postID=2008420148976627895' title='40 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/455416252368984615/posts/default/2008420148976627895'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/455416252368984615/posts/default/2008420148976627895'/><link rel='alternate' type='text/html' href='http://happypython.blogspot.com/2009/11/generating-svg-output-from-graphviz-in.html' title='Generating SVG Output (from Graphviz) in your Django App'/><author><name>Matt Franz</name><uri>http://www.blogger.com/profile/00973881935128108475</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_MPIoEEC-IC0/SWXZy3zT_TI/AAAAAAAABHY/FmMm-co3m0Y/S220/blah.jpg'/></author><thr:total>40</thr:total></entry><entry><id>tag:blogger.com,1999:blog-455416252368984615.post-5139200790580955939</id><published>2008-12-13T07:53:00.000-08:00</published><updated>2008-12-13T07:55:40.145-08:00</updated><title type='text'>Google Protocol Buffers</title><content type='html'>&lt;a href="http://code.google.com/apis/protocolbuffers/docs/overview.html"&gt;Google Protocol Buffers&lt;/a&gt; was mentioned on the Python LinkedIn Community. &lt;br /&gt;&lt;blockquote&gt;&lt;br /&gt;Protocol buffers are a flexible, efficient, automated mechanism for serializing structured data – think XML, but smaller, faster, and simpler. You define how you want your data to be structured once, then you can use special generated source code to easily write and read your structured data to and from a variety of data streams and using a variety of languages. You can even update your data structure without breaking deployed programs that are compiled against the "old" format.&lt;br /&gt;&lt;/blockquote&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://code.google.com/apis/protocolbuffers/docs/reference/python/index.html"&gt;Here&lt;/a&gt; is the Link to the Python API.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/455416252368984615-5139200790580955939?l=happypython.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://happypython.blogspot.com/feeds/5139200790580955939/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=455416252368984615&amp;postID=5139200790580955939' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/455416252368984615/posts/default/5139200790580955939'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/455416252368984615/posts/default/5139200790580955939'/><link rel='alternate' type='text/html' href='http://happypython.blogspot.com/2008/12/google-protocol-buffers.html' title='Google Protocol Buffers'/><author><name>Matt Franz</name><uri>http://www.blogger.com/profile/00973881935128108475</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_MPIoEEC-IC0/SWXZy3zT_TI/AAAAAAAABHY/FmMm-co3m0Y/S220/blah.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-455416252368984615.post-5512029352898587124</id><published>2008-12-06T16:49:00.000-08:00</published><updated>2008-12-06T16:55:20.055-08:00</updated><title type='text'>Talking 3.0</title><content type='html'>&lt;object width="425" height="344"&gt;&lt;param name="movie" value="http://www.youtube.com/v/I8pyv9FiMcg&amp;hl=en&amp;fs=1"&gt;&lt;/param&gt;&lt;param name="allowFullScreen" value="true"&gt;&lt;/param&gt;&lt;param name="allowscriptaccess" value="always"&gt;&lt;/param&gt;&lt;embed src="http://www.youtube.com/v/I8pyv9FiMcg&amp;hl=en&amp;fs=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;br /&gt;&lt;br /&gt;I'm embarrassed to say I've hardly touched 2.6 let alone 3.0 but &lt;a href="http://www.b-list.org/weblog/2008/dec/05/python-3000/"&gt;Let's talk about Python 3.0&lt;/a&gt; has some interesting background on the limitations of Python 2.x as well as thoughts on process improvement&lt;br /&gt;&lt;blockquote&gt;&lt;br /&gt;This is a startlingly good analogy for the way lots of corporations do things; once a particular process is entrenched (and especially after a couple rounds of employee turnover), there’s nobody left who remembers why the company does things this way. There’s nobody who stops to think about whether this is still a good way to do things, or whether it was even a good idea way back at the beginning. The process continues through nothing more than inertia, and anyone who suggests a change is likely to end up viciously attacked by monkeys. &lt;br /&gt;&lt;/blockquote&gt;&lt;br /&gt;&lt;br /&gt;Of course CentOS5 still only comes with Python 2.4.3, which is what I'm stuck for much of my development unless is compile from scratch.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/455416252368984615-5512029352898587124?l=happypython.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://happypython.blogspot.com/feeds/5512029352898587124/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=455416252368984615&amp;postID=5512029352898587124' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/455416252368984615/posts/default/5512029352898587124'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/455416252368984615/posts/default/5512029352898587124'/><link rel='alternate' type='text/html' href='http://happypython.blogspot.com/2008/12/talking-30.html' title='Talking 3.0'/><author><name>Matt Franz</name><uri>http://www.blogger.com/profile/00973881935128108475</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_MPIoEEC-IC0/SWXZy3zT_TI/AAAAAAAABHY/FmMm-co3m0Y/S220/blah.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-455416252368984615.post-1539744842186243710</id><published>2008-11-21T17:19:00.000-08:00</published><updated>2008-11-21T17:21:42.889-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='django'/><title type='text'>Back to my Labor Day App</title><content type='html'>One of the best rules of programming is to leave your code alone if you are banging your head against a problem. &lt;a href="http://happypython.blogspot.com/2008/09/rundown-on-django-upgrade-problems-and.html"&gt;When upgrading to 1.0&lt;/a&gt; Well I finally fixed the issue with my admin interface. It helps if you put admin.py in the right directory!&lt;br /&gt;&lt;br /&gt;Within the app instead of the project.&lt;br /&gt;&lt;br /&gt;DOH!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/455416252368984615-1539744842186243710?l=happypython.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://happypython.blogspot.com/feeds/1539744842186243710/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=455416252368984615&amp;postID=1539744842186243710' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/455416252368984615/posts/default/1539744842186243710'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/455416252368984615/posts/default/1539744842186243710'/><link rel='alternate' type='text/html' href='http://happypython.blogspot.com/2008/11/back-to-my-labor-day-app.html' title='Back to my Labor Day App'/><author><name>Matt Franz</name><uri>http://www.blogger.com/profile/00973881935128108475</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_MPIoEEC-IC0/SWXZy3zT_TI/AAAAAAAABHY/FmMm-co3m0Y/S220/blah.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-455416252368984615.post-3120625699359961643</id><published>2008-09-27T06:56:00.000-07:00</published><updated>2008-09-27T06:59:10.049-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Systems'/><title type='text'>Func: Python Systems Management</title><content type='html'>&lt;a href="https://fedorahosted.org/func"&gt;Func: Fedora Unified Network Controller&lt;/a&gt; looks pretty interesting.&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;&lt;br /&gt;A lot of programs, systems, and tools need some way to communicate. Func provides a two-way authenticated system for generically doing these sort of things. You can build your own applications on top of it, and easily expand func by adding in additional modules, whether you want these to work through the func command line or by means of some other application. If you just want to use the func command line, that's great. If you want to build apps on the func tools, that's great too. If this sounds generically vague, it's only because it really is that expandable.&lt;br /&gt;&lt;/blockquote&gt;&lt;br /&gt;&lt;br /&gt;With some examples&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;# func target.example.org call hardware info&lt;br /&gt;# func "*.example.org" call yumcmd update&lt;br /&gt;# func "*" call moduleyouwrote functionname 1234 5678 firetruck acmelabs hike! &lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/455416252368984615-3120625699359961643?l=happypython.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://happypython.blogspot.com/feeds/3120625699359961643/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=455416252368984615&amp;postID=3120625699359961643' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/455416252368984615/posts/default/3120625699359961643'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/455416252368984615/posts/default/3120625699359961643'/><link rel='alternate' type='text/html' href='http://happypython.blogspot.com/2008/09/func-python-systems-management.html' title='Func: Python Systems Management'/><author><name>Matt Franz</name><uri>http://www.blogger.com/profile/00973881935128108475</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_MPIoEEC-IC0/SWXZy3zT_TI/AAAAAAAABHY/FmMm-co3m0Y/S220/blah.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-455416252368984615.post-7612752669246425709</id><published>2008-09-21T14:10:00.000-07:00</published><updated>2008-09-21T14:15:31.998-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='tricks projects'/><title type='text'>Converting Subnet to CIDR in Python</title><content type='html'>A &lt;a href="http://code.activestate.com/recipes/576483/"&gt;nice recipe&lt;/a&gt;, here is the meat of an even faster version in the comments.&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;def calcDottedNetmask(mask):&lt;br /&gt;    bits = 0xffffffff ^ (1 &lt;&lt; 32 - mask) - 1&lt;br /&gt;    return inet_ntoa(pack('&gt;I', bits))&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Which also led me to &lt;a href="http://code.google.com/p/netaddr/"&gt;the Python netaddr&lt;/a&gt; project. Very cool!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/455416252368984615-7612752669246425709?l=happypython.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://happypython.blogspot.com/feeds/7612752669246425709/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=455416252368984615&amp;postID=7612752669246425709' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/455416252368984615/posts/default/7612752669246425709'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/455416252368984615/posts/default/7612752669246425709'/><link rel='alternate' type='text/html' href='http://happypython.blogspot.com/2008/09/converting-subnet-to-cidr-in-python.html' title='Converting Subnet to CIDR in Python'/><author><name>Matt Franz</name><uri>http://www.blogger.com/profile/00973881935128108475</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_MPIoEEC-IC0/SWXZy3zT_TI/AAAAAAAABHY/FmMm-co3m0Y/S220/blah.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-455416252368984615.post-7659150406516777913</id><published>2008-09-21T13:50:00.000-07:00</published><updated>2008-09-21T14:04:03.614-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='django'/><title type='text'>Rundown on Django 1.0 Upgrade Problems (and Solutions)</title><content type='html'>I've been too swamped with my teaching lately to make much progress on a &lt;a href="http://happypython.blogspot.com/2008/09/and-how-easy-is-django-csv.html"&gt;little app&lt;/a&gt; I initially wrote in 0.96.2 and have been trying to port to 1.0.&lt;br /&gt;&lt;br /&gt;Besides some bonehead typos that wasted a lot of time, here are the summary of issues I've run across:&lt;div&gt;&lt;ol&gt;&lt;li&gt;Creation of the new admin.py&lt;/li&gt;&lt;li&gt;Modifications of urls.py&lt;/li&gt;&lt;li&gt;Conversion between max_length and maxlength in your modles&lt;/li&gt;&lt;/ol&gt;I still don't have my admin interfaces working even though I've followed the exact steps, so I'm sure it is something else.&lt;br /&gt;&lt;br /&gt;The main problems related to the admin interface, but there are a number of resources I've run across including &lt;a href="http://docs.djangoproject.com/en/dev/releases/1.0-porting-guide/"&gt;Porting your apps from Django 0.96 to 1.0&lt;/a&gt; and &lt;a href="http://code.djangoproject.com/wiki/BackwardsIncompatibleChanges"&gt;the complete list of backward incompatible changes&lt;/a&gt; and a &lt;a href="http://www.djangosnippets.org/snippets/603/"&gt;conversion script&lt;/a&gt; to create the new admin interface conversion.&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/455416252368984615-7659150406516777913?l=happypython.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://happypython.blogspot.com/feeds/7659150406516777913/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=455416252368984615&amp;postID=7659150406516777913' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/455416252368984615/posts/default/7659150406516777913'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/455416252368984615/posts/default/7659150406516777913'/><link rel='alternate' type='text/html' href='http://happypython.blogspot.com/2008/09/rundown-on-django-upgrade-problems-and.html' title='Rundown on Django 1.0 Upgrade Problems (and Solutions)'/><author><name>Matt Franz</name><uri>http://www.blogger.com/profile/00973881935128108475</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_MPIoEEC-IC0/SWXZy3zT_TI/AAAAAAAABHY/FmMm-co3m0Y/S220/blah.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-455416252368984615.post-1283235829375241693</id><published>2008-09-01T05:14:00.000-07:00</published><updated>2008-09-01T05:23:06.509-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='django'/><title type='text'>And how easy is Django CSV?</title><content type='html'>I'm a few hours (and of course I already have a functional app) into converting a spreadsheet "database" we currently store on Sharepoint with a Django app and I was pleased to see how &lt;a href="http://www.djangoproject.com/documentation/0.96/outputting_csv/"&gt;easy it was to do CSV dumps&lt;/a&gt; of data. And it worked on the first time. Amazing.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/455416252368984615-1283235829375241693?l=happypython.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://happypython.blogspot.com/feeds/1283235829375241693/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=455416252368984615&amp;postID=1283235829375241693' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/455416252368984615/posts/default/1283235829375241693'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/455416252368984615/posts/default/1283235829375241693'/><link rel='alternate' type='text/html' href='http://happypython.blogspot.com/2008/09/and-how-easy-is-django-csv.html' title='And how easy is Django CSV?'/><author><name>Matt Franz</name><uri>http://www.blogger.com/profile/00973881935128108475</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_MPIoEEC-IC0/SWXZy3zT_TI/AAAAAAAABHY/FmMm-co3m0Y/S220/blah.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-455416252368984615.post-5574932314180407391</id><published>2008-05-11T06:35:00.000-07:00</published><updated>2008-05-11T06:53:07.593-07:00</updated><title type='text'>And CherryPy Looks to be the Winner</title><content type='html'>&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_MPIoEEC-IC0/SCb4vHqxSZI/AAAAAAAAAdE/K4LdR_cka9s/s1600-h/cplogo.jpg"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;" src="http://2.bp.blogspot.com/_MPIoEEC-IC0/SCb4vHqxSZI/AAAAAAAAAdE/K4LdR_cka9s/s400/cplogo.jpg" border="0" alt=""id="BLOGGER_PHOTO_ID_5199116308241795474" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;So I've been &lt;a href="http://happypython.blogspot.com/2008/05/from-aspen-to-karrigell-and-webpy.html"&gt;looking for a pure Python lightweight HTTP server&lt;/a&gt; for serving up a small django app.&lt;br /&gt;&lt;br /&gt;Here are the steps I used (assuming Django is already installed however you installed it) for Ubuntu Hardy LTS:&lt;br /&gt;&lt;br /&gt;1) Install &lt;a href="http://www.cherrypy.org/"&gt;CherryPy&lt;/a&gt; 3.x (I installed the &lt;b&gt;python-cherrypy3&lt;/b&gt; package)&lt;br /&gt;&lt;br /&gt;2) Get &lt;a href="http://www.xhtml.net/scripts/Django-CherryPy-server-DjangoCerise"&gt;DjangoCerise&lt;/a&gt; and follow the docs. Documentation and these wrapper scripts were the make or break difference.&lt;br /&gt;&lt;br /&gt;3) Increase number of threads in th e SERVER_THREADS file. My crude app worked fine but the django admin interface was a bit sluggish.&lt;br /&gt;&lt;br /&gt;While it properly daemonizes (possibly because I screwed up the scripts) shutdown wasn't working for me and (quite obviously, in hindsight) unless you run the startup scripts as root (which I will be) once this app qoes into "production" it won't properly set the user to nobody.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/455416252368984615-5574932314180407391?l=happypython.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://happypython.blogspot.com/feeds/5574932314180407391/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=455416252368984615&amp;postID=5574932314180407391' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/455416252368984615/posts/default/5574932314180407391'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/455416252368984615/posts/default/5574932314180407391'/><link rel='alternate' type='text/html' href='http://happypython.blogspot.com/2008/05/and-cherrypy-looks-to-be-winner.html' title='And CherryPy Looks to be the Winner'/><author><name>Matt Franz</name><uri>http://www.blogger.com/profile/00973881935128108475</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_MPIoEEC-IC0/SWXZy3zT_TI/AAAAAAAABHY/FmMm-co3m0Y/S220/blah.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_MPIoEEC-IC0/SCb4vHqxSZI/AAAAAAAAAdE/K4LdR_cka9s/s72-c/cplogo.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-455416252368984615.post-6425432776309232452</id><published>2008-05-10T19:14:00.000-07:00</published><updated>2008-05-10T19:25:06.621-07:00</updated><title type='text'>From Aspen to Karrigell and web.py</title><content type='html'>Been struggling to get &lt;a href="http://www.zetadev.com/software/aspen/"&gt;Aspen&lt;/a&gt; working with Django. My app works fine, still having issues with "static" apps, which are necessary for the media directory and I ran across two framworks I hadn't seen before.&lt;br /&gt;&lt;br /&gt;The first was &lt;a href="http://karrigell.sourceforge.net/"&gt;Karrigell&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;&lt;br /&gt;Karrigell is a flexible Python web framework, with a clear and intuitive syntax. It is independant from any database, ORM or templating engine, and lets the programmer choose between a variety of coding styles&lt;br /&gt;&lt;br /&gt;The package includes a powerful built-in web server, so there's no need to download, install and configure a separate one, and a pure-Python database engine, PyDbLite, which is used for the demos &lt;br /&gt;&lt;/blockquote&gt;&lt;br /&gt;&lt;br /&gt;and another was &lt;a href="http://webpy.org/"&gt;web.py&lt;/a&gt; which is so barebones it is not worth quoting the website.&lt;br /&gt;&lt;br /&gt;I doubt I'll use either of these, in particular I'm not sure the point of using a web framework unless there is an ORM?&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/455416252368984615-6425432776309232452?l=happypython.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://happypython.blogspot.com/feeds/6425432776309232452/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=455416252368984615&amp;postID=6425432776309232452' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/455416252368984615/posts/default/6425432776309232452'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/455416252368984615/posts/default/6425432776309232452'/><link rel='alternate' type='text/html' href='http://happypython.blogspot.com/2008/05/from-aspen-to-karrigell-and-webpy.html' title='From Aspen to Karrigell and web.py'/><author><name>Matt Franz</name><uri>http://www.blogger.com/profile/00973881935128108475</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_MPIoEEC-IC0/SWXZy3zT_TI/AAAAAAAABHY/FmMm-co3m0Y/S220/blah.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-455416252368984615.post-933201749006721173</id><published>2008-04-25T06:28:00.000-07:00</published><updated>2008-04-25T06:31:43.036-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='django'/><title type='text'>No Model Inheritence in Django?</title><content type='html'>Based on &lt;a href="http://code.djangoproject.com/wiki/ModelInheritance"&gt;this wiki page on Model Inheritance&lt;/a&gt; and this &lt;a href="http://www.fadingred.org/blog/articles/2007/03/02/extending-djangos-model-class/"&gt;hack on extending models&lt;/a&gt; (yuck) not looking too good. I would guess this "just works" in Rails, since I've just redesigned my database now would be the time to switch but I really want Django's admin interface.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/455416252368984615-933201749006721173?l=happypython.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://happypython.blogspot.com/feeds/933201749006721173/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=455416252368984615&amp;postID=933201749006721173' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/455416252368984615/posts/default/933201749006721173'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/455416252368984615/posts/default/933201749006721173'/><link rel='alternate' type='text/html' href='http://happypython.blogspot.com/2008/04/no-model-inheritence-in-django.html' title='No Model Inheritence in Django?'/><author><name>Matt Franz</name><uri>http://www.blogger.com/profile/00973881935128108475</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_MPIoEEC-IC0/SWXZy3zT_TI/AAAAAAAABHY/FmMm-co3m0Y/S220/blah.jpg'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-455416252368984615.post-1775297784641881643</id><published>2008-04-17T19:10:00.000-07:00</published><updated>2008-04-17T19:13:38.990-07:00</updated><title type='text'>Not Too Happy with Django Migration</title><content type='html'>So after playing around with &lt;a href="http://code.google.com/p/dmigrate/"&gt;dmigration&lt;/a&gt; and &lt;a href="http://www.aswmc.com/dbmigration/"&gt;dbmigration&lt;/a&gt; I'm probably going back to mucking with SQL (which I'm even less happy) or maybe hacking something together that meets my needs and actually works.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/455416252368984615-1775297784641881643?l=happypython.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://happypython.blogspot.com/feeds/1775297784641881643/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=455416252368984615&amp;postID=1775297784641881643' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/455416252368984615/posts/default/1775297784641881643'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/455416252368984615/posts/default/1775297784641881643'/><link rel='alternate' type='text/html' href='http://happypython.blogspot.com/2008/04/not-too-happy-with-django-migration.html' title='Not Too Happy with Django Migration'/><author><name>Matt Franz</name><uri>http://www.blogger.com/profile/00973881935128108475</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_MPIoEEC-IC0/SWXZy3zT_TI/AAAAAAAABHY/FmMm-co3m0Y/S220/blah.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-455416252368984615.post-2133718224177322989</id><published>2008-03-02T10:53:00.000-08:00</published><updated>2008-03-02T10:57:00.993-08:00</updated><title type='text'>fun with ieeemac</title><content type='html'>This week I count have actually used &lt;a href="http://pypi.python.org/pypi?%3Aaction=search&amp;term=ieeemac&amp;submit=search"&gt;ieeemac&lt;/a&gt;  when I was writing some scripts to automate packet generation using Click Router.&lt;br /&gt;&lt;br /&gt;But of course I was using Ruby so I couldn't take advantage of this.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;&gt;&gt;&gt; import ieeemac&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;&gt;&gt;&gt; import commands&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;&gt;&gt;&gt; o = commands.getoutput("ifconfig -a") &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;&gt;&gt;&gt; o&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;'lo0: flags=8049&lt;up,loopback,running,multicast&gt; mtu 16384\n\tinet 127.0.0.1 netmask 0xff000000 \n\tinet6 ::1 prefixlen 128 \n\tinet6 fe80::1%lo0 prefixlen 64 scopeid 0x1 \ngif0: flags=8010&lt;pointopoint,multicast&gt; mtu 1280\nstf0: flags=0&lt;&gt; mtu 1280\nen0: flags=8863&lt;up,broadcast,smart,running,simplex,multicast&gt; mtu 1500\n\tether 00:11:24:45:4b:1a \n\tmedia: autoselect (none) status: inactive\n\tsupported media: none autoselect 10baseT/UTP &lt;half-duplex&gt; 10baseT/UTP &lt;full-duplex&gt; 10baseT/UTP &lt;full-duplex,hw-loopback&gt; 100baseTX &lt;half-duplex&gt; 100baseTX &lt;full-duplex&gt; 100baseTX &lt;full-duplex,hw-loopback&gt;\nen1: flags=8863&lt;up,broadcast,smart,running,simplex,multicast&gt; mtu 1500\n\tinet6 fe80::211:24ff:fea4:9fc7%en1 prefixlen 64 scopeid 0x5 \n\tinet 192.168.1.103 netmask 0xffffff00 broadcast 192.168.1.255\n\tether 00:11:24:a4:9f:c7 \n\tmedia: autoselect status: active\n\tsupported media: autoselect\nfw0: flags=8863&lt;up,broadcast,smart,running,simplex,multicast&gt; mtu 2030\n\tlladdr 00:11:24:ff:fe:45:4b:1a \n\tmedia: autoselect &lt;full-duplex&gt; status: inactive\n\tsupported media: autoselect &lt;full-duplex&gt;\nwlt1: flags=41&lt;up,running&gt; mtu 1500\ntap0: flags=8842&lt;broadcast,running,simplex,multicast&gt; mtu 1500\n\tether 74:61:70:00:00:00 \n\tclosed\ntun0: flags=8850&lt;pointopoint,running,simplex,multicast&gt; mtu 1500\n\tclosed'&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;&gt;&gt;&gt; ieeemac.find_macs(o)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;[&lt;ieeemac.mac&gt;, &lt;ieeemac.mac&gt;, &lt;ieeemac.mac&gt;, &lt;ieeemac.mac&gt;]&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;&gt;&gt;&gt; ml = ieeemac.find_macs(o)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;&gt;&gt;&gt; ml&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;[&lt;ieeemac.mac&gt;, &lt;ieeemac.mac&gt;, &lt;ieeemac.mac&gt;, &lt;ieeemac.mac&gt;]&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;&gt;&gt;&gt; ml[0]  &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;&lt;ieeemac.mac&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;&gt;&gt;&gt; dir(ml[0])&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;['__doc__', '__eq__', '__getattr__', '__init__', '__module__', '__str__', '_formats', 'format', 'formats', 'groups', 'groups_need_fixing', 'to_format']&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;&gt;&gt;&gt; ml[0].to_format("cisco")&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;'0011.2445.4b1a'&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/455416252368984615-2133718224177322989?l=happypython.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://happypython.blogspot.com/feeds/2133718224177322989/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=455416252368984615&amp;postID=2133718224177322989' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/455416252368984615/posts/default/2133718224177322989'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/455416252368984615/posts/default/2133718224177322989'/><link rel='alternate' type='text/html' href='http://happypython.blogspot.com/2008/03/fun-with-ieeemac.html' title='fun with ieeemac'/><author><name>Matt Franz</name><uri>http://www.blogger.com/profile/00973881935128108475</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_MPIoEEC-IC0/SWXZy3zT_TI/AAAAAAAABHY/FmMm-co3m0Y/S220/blah.jpg'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-455416252368984615.post-2878124354240195337</id><published>2008-02-24T12:57:00.000-08:00</published><updated>2008-02-24T12:59:54.851-08:00</updated><title type='text'>Easy Win32 Python and Registry</title><content type='html'>So I have some experience with APIs for accessing the registry (when I wrote some SCADA  Nessus Plugins) but it can't get any easier than this &lt;a href="http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/546543"&gt;recipe&lt;/a&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/455416252368984615-2878124354240195337?l=happypython.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://happypython.blogspot.com/feeds/2878124354240195337/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=455416252368984615&amp;postID=2878124354240195337' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/455416252368984615/posts/default/2878124354240195337'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/455416252368984615/posts/default/2878124354240195337'/><link rel='alternate' type='text/html' href='http://happypython.blogspot.com/2008/02/easy-win32-python-and-registry.html' title='Easy Win32 Python and Registry'/><author><name>Matt Franz</name><uri>http://www.blogger.com/profile/00973881935128108475</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_MPIoEEC-IC0/SWXZy3zT_TI/AAAAAAAABHY/FmMm-co3m0Y/S220/blah.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-455416252368984615.post-4357160662890413647</id><published>2008-01-13T19:57:00.000-08:00</published><updated>2008-01-13T20:03:04.599-08:00</updated><title type='text'>NetworkX: This I might actually find time to play with</title><content type='html'>&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_MPIoEEC-IC0/R4renLWpIiI/AAAAAAAAARs/w4jWu7RjAZU/s1600-h/networx.png"&gt;&lt;img style="float:left; margin:0 10px 10px 0;cursor:pointer; cursor:hand;" src="http://2.bp.blogspot.com/_MPIoEEC-IC0/R4renLWpIiI/AAAAAAAAARs/w4jWu7RjAZU/s200/networx.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5155177488122978850" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Just ran across &lt;a href="https://networkx.lanl.gov/wiki"&gt;NetworkX&lt;/a&gt; tonight:&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;&lt;br /&gt;NetworkX (NX) is a Python package for the creation, manipulation, and study of the structure, dynamics, and functions of complex networks. Features: Includes standard graph-theoretic and statistical physics functions, Easy exchange of network algorithms between applications, disciplines, and platforms, Includes many classic graphs and synthetic networks, Nodes and edges can be "anything" (e.g. time-series, text, images, XML records)&lt;br /&gt;&lt;/blockquote&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/455416252368984615-4357160662890413647?l=happypython.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://happypython.blogspot.com/feeds/4357160662890413647/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=455416252368984615&amp;postID=4357160662890413647' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/455416252368984615/posts/default/4357160662890413647'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/455416252368984615/posts/default/4357160662890413647'/><link rel='alternate' type='text/html' href='http://happypython.blogspot.com/2008/01/networkx-this-i-might-actually-find.html' title='NetworkX: This I might actually find time to play with'/><author><name>Matt Franz</name><uri>http://www.blogger.com/profile/00973881935128108475</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_MPIoEEC-IC0/SWXZy3zT_TI/AAAAAAAABHY/FmMm-co3m0Y/S220/blah.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_MPIoEEC-IC0/R4renLWpIiI/AAAAAAAAARs/w4jWu7RjAZU/s72-c/networx.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-455416252368984615.post-8396671616353796073</id><published>2008-01-04T19:05:00.000-08:00</published><updated>2008-01-04T19:11:00.097-08:00</updated><title type='text'>A Better Python Cmd Library</title><content type='html'>The Python &lt;a href="http://docs.python.org/lib/module-cmd.html"&gt;cmd module&lt;/a&gt; has always been been better than the &lt;a href="https://rubyforge.org/projects/cmd/"&gt;Ruby imitation&lt;/a&gt; (after all like most things about Ruby, it is cheap copy of the original, distinctive feel?) but &lt;a href="https://sourceforge.net/projects/python-cmd2"&gt;cmd2&lt;/a&gt; turns this into a real ass-kicking with the following features:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt; * Searchable command history (commands: "hi", "li", "run")&lt;br /&gt; * Load commands from file, save to file, edit commands in file&lt;br /&gt; * Multi-line commands&lt;br /&gt; * Case-insensitive commands&lt;br /&gt; * Special-character shortcut commands (beyond cmd's "@" and "!")&lt;br /&gt; * Settable environment parameters&lt;br /&gt; * Parsing commands with flags&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/455416252368984615-8396671616353796073?l=happypython.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://happypython.blogspot.com/feeds/8396671616353796073/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=455416252368984615&amp;postID=8396671616353796073' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/455416252368984615/posts/default/8396671616353796073'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/455416252368984615/posts/default/8396671616353796073'/><link rel='alternate' type='text/html' href='http://happypython.blogspot.com/2008/01/better-python-cmd-library.html' title='A Better Python Cmd Library'/><author><name>Matt Franz</name><uri>http://www.blogger.com/profile/00973881935128108475</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_MPIoEEC-IC0/SWXZy3zT_TI/AAAAAAAABHY/FmMm-co3m0Y/S220/blah.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-455416252368984615.post-2728217370759208297</id><published>2008-01-04T18:59:00.000-08:00</published><updated>2008-01-04T19:02:44.382-08:00</updated><title type='text'>Django on Jython?</title><content type='html'>I previously &lt;a href="http://blogfranz.blogspot.com/2007/08/non-jython-news-and-irrelevance-of.html"&gt;whined about the non-progress of Jython&lt;/a&gt; (especially relative to JRuby) but &lt;a href="http://zyasoft.com/pythoneering/2008/01/django-on-jython-minding-gap.html"&gt;this is great news&lt;/a&gt;.&lt;br /&gt;&lt;blockquote&gt;&lt;br /&gt;The most important thing to know about Django on Jython is that we are almost there, and with clean code. End-to-end functionality is demonstrated by the admin tool running in full CRUD, along with a substantial number of unit tests and syncdb.&lt;br /&gt;&lt;/blockquote&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/455416252368984615-2728217370759208297?l=happypython.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://happypython.blogspot.com/feeds/2728217370759208297/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=455416252368984615&amp;postID=2728217370759208297' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/455416252368984615/posts/default/2728217370759208297'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/455416252368984615/posts/default/2728217370759208297'/><link rel='alternate' type='text/html' href='http://happypython.blogspot.com/2008/01/django-on-jython.html' title='Django on Jython?'/><author><name>Matt Franz</name><uri>http://www.blogger.com/profile/00973881935128108475</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_MPIoEEC-IC0/SWXZy3zT_TI/AAAAAAAABHY/FmMm-co3m0Y/S220/blah.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-455416252368984615.post-1791091581862653593</id><published>2008-01-02T08:51:00.000-08:00</published><updated>2008-01-02T08:53:22.663-08:00</updated><title type='text'>Maybe someday I'll have time to read on Python Bytecode</title><content type='html'>Maybe someday I'll get a chance to fully digest&lt;a href="http://thermalnoise.wordpress.com/2007/12/30/exploring-python-bytecode/"&gt;Exploring Python Bytecode&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;&lt;br /&gt;For the past month or so, I’ve been trying to understand what appears to be a black art mostly because of lacking documentation - Python bytecode generation and peephole optimization. Some notes from the study for the benefit of IRC-mate ‘jstatm’ and anyone else living on similar planes of insanity.&lt;br /&gt;&lt;br /&gt;Although bytecode applies to objects other than functions such as tracebacks, dictionaries and strings, I am only interested in optimization and flow analysis of class methods, functions and lambdas. Lets get to the action straight away with an example. Here is a small python program to disassemble and display the bytecode of a function in human readable form.&lt;br /&gt;&lt;/blockquote&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/455416252368984615-1791091581862653593?l=happypython.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://happypython.blogspot.com/feeds/1791091581862653593/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=455416252368984615&amp;postID=1791091581862653593' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/455416252368984615/posts/default/1791091581862653593'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/455416252368984615/posts/default/1791091581862653593'/><link rel='alternate' type='text/html' href='http://happypython.blogspot.com/2008/01/maybe-someday-ill-have-time-to-read-on.html' title='Maybe someday I&apos;ll have time to read on Python Bytecode'/><author><name>Matt Franz</name><uri>http://www.blogger.com/profile/00973881935128108475</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_MPIoEEC-IC0/SWXZy3zT_TI/AAAAAAAABHY/FmMm-co3m0Y/S220/blah.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-455416252368984615.post-9021294412593986361</id><published>2008-01-01T07:57:00.000-08:00</published><updated>2008-01-01T07:58:09.158-08:00</updated><title type='text'>Decorators, Python Black Magic and the Residue of Past Programming</title><content type='html'>While trying to figure out &lt;a href="http://www.threatmind.net/secwiki/PythonDecorators"&gt;decorators&lt;/a&gt; I ran across a really cool presentation called &lt;a href="http://www.python.ie/blackmagic/"&gt;Python Black Magic (or how I learned to stop writing Java in Python)&lt;/a&gt;. I understand this, since much of the Python I've written over the years, was even worse -- &lt;i&gt;I was writing Perl in Python&lt;/i&gt;. For the longest time Python OO conventions seemed strange compared to Java/C# and I refused to use them sticking to horrific &lt;a href="http://blogfranz.blogspot.com/2007/12/using-hashes-like-it-is-1999.html"&gt;Perl-like hash of a hash of a hash data structures.&lt;/a&gt; On the one hand if you are sort of programming-ADD-like-me, I definitely see the advantage of developing a set of crisp clean, language agnostic design patters. Who cares if your code isn't completely Pythonic or if you aren't exploiting all the Ruby functional programming fu, your code will be accessible to the largest possible audience.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/455416252368984615-9021294412593986361?l=happypython.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://happypython.blogspot.com/feeds/9021294412593986361/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=455416252368984615&amp;postID=9021294412593986361' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/455416252368984615/posts/default/9021294412593986361'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/455416252368984615/posts/default/9021294412593986361'/><link rel='alternate' type='text/html' href='http://happypython.blogspot.com/2008/01/decorators-python-black-magic-and.html' title='Decorators, Python Black Magic and the Residue of Past Programming'/><author><name>Matt Franz</name><uri>http://www.blogger.com/profile/00973881935128108475</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_MPIoEEC-IC0/SWXZy3zT_TI/AAAAAAAABHY/FmMm-co3m0Y/S220/blah.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-455416252368984615.post-5831432732270968392</id><published>2007-12-28T21:16:00.001-08:00</published><updated>2007-12-28T21:24:45.258-08:00</updated><title type='text'>Web Scripting with Twill (I wish I had this when I used to do WebApp Assessments)</title><content type='html'>A few weeks ago I thought I had the need to script (for the life of my I can't remember why I wanted to do this, I should have blogged on it) Firefox. Well I didn't any Python or Ruby tools for taking control of the browser (I remember seeing how to do this with Python and IE a loooong time ago) but tonight I ran across &lt;a href="http://twill.idyll.org/"&gt;Twill&lt;/a&gt; which looks pretty cool and I assume uses the &lt;a href="http://www.blogger.com/%20http://docs.python.org/lib/module-cmd.html"&gt;cmd module&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;mfranz@gutsy61:~$ twill-sh&lt;br /&gt;&lt;br /&gt;-= Welcome to twill! =-&lt;br /&gt;&lt;br /&gt;current page:  *empty page*&lt;br /&gt;&lt;br /&gt;&gt;&gt; go http://www.threatmind.net/secwiki&lt;br /&gt;==&gt; at http://www.threatmind.net/secwiki&lt;br /&gt;current page: http://www.threatmind.net/secwiki&lt;br /&gt;&gt;&gt; showforms&lt;br /&gt;&lt;br /&gt;Form #1&lt;br /&gt;## ## __Name__________________ __Type___ __ID________ __Value__________________&lt;br /&gt;1     action                   hidden    (None)       fullsearch&lt;br /&gt;2     context                  hidden    (None)       180&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;3     value                    text      searchinput&lt;br /&gt;4  1  titlesearch              submit    titlesearch  Titles&lt;br /&gt;5  2  fullsearch               submit    fullsearch   Text&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Form #2&lt;br /&gt;## ## __Name__________________ __Type___ __ID________ __Value__________________&lt;br /&gt;1     action                   select    (None)       ['raw'] of ['raw', 'print', 'refresh ...&lt;br /&gt;2  1  None                     submit    (None)       Do&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Form #3&lt;br /&gt;## ## __Name__________________ __Type___ __ID________ __Value__________________&lt;br /&gt;1     action                   select    (None)       ['raw'] of ['raw', 'print', 'refresh ...&lt;br /&gt;2  1  None                     submit    (None)       Do&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;current page: http://www.threatmind.net/secwiki&lt;br /&gt;&gt;&gt; help&lt;br /&gt;&lt;br /&gt;Undocumented commands:&lt;br /&gt;======================&lt;br /&gt;add_auth             fa           info             save_html           title&lt;br /&gt;add_extra_header     find         load_cookies     setglobal           url&lt;br /&gt;agent                follow       notfind          setlocal       &lt;br /&gt;back                 formaction   redirect_error   show           &lt;br /&gt;clear_cookies        formclear    redirect_output  show_cookies   &lt;br /&gt;clear_extra_headers  formfile     reload           show_extra_headers&lt;br /&gt;code                 formvalue    reset_browser    showforms      &lt;br /&gt;config               fv           reset_error      showhistory    &lt;br /&gt;debug                get_browser  reset_output     showlinks      &lt;br /&gt;echo                 getinput     run              sleep          &lt;br /&gt;exit                 getpassword  runfile          submit         &lt;br /&gt;extend_with          go           save_cookies     tidy_ok&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/455416252368984615-5831432732270968392?l=happypython.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://happypython.blogspot.com/feeds/5831432732270968392/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=455416252368984615&amp;postID=5831432732270968392' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/455416252368984615/posts/default/5831432732270968392'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/455416252368984615/posts/default/5831432732270968392'/><link rel='alternate' type='text/html' href='http://happypython.blogspot.com/2007/12/web-scripting-with-twill-i-wish-i-had.html' title='Web Scripting with Twill (I wish I had this when I used to do WebApp Assessments)'/><author><name>Matt Franz</name><uri>http://www.blogger.com/profile/00973881935128108475</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_MPIoEEC-IC0/SWXZy3zT_TI/AAAAAAAABHY/FmMm-co3m0Y/S220/blah.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-455416252368984615.post-5053437977004761374</id><published>2007-12-27T14:35:00.000-08:00</published><updated>2007-12-27T17:56:42.386-08:00</updated><title type='text'>Obviously I'm not Even an Intermediate Level Python Programmer</title><content type='html'>While a thread on &lt;a href="http://groups.google.com/group/comp.lang.python/browse_thread/thread/527cafad9c341490/"&gt;regex performance&lt;/a&gt; revealed how much I've forgotten (or never knew) even though I started coding in Python (1.5.x) back in 1999. My confusion didn't have really anything to do with regexes but the two different approaches, one which was more peculiar to my only-coding-in-Ruby-recently brain:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Class Approach&lt;/span&gt;&lt;br /&gt;&lt;pre&gt;import re&lt;br /&gt;class Searcher(object):&lt;br /&gt;  def __init__(self, rex):&lt;br /&gt;     self.crex = re.compile(rex)&lt;br /&gt;  def __call__(self, txt):&lt;br /&gt;     return self.crex.search(txt)&lt;br /&gt;&lt;br /&gt;s = Searcher("dog")&lt;br /&gt;print s("dog").string&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;After I remembered what the &lt;span style="font-family: courier new;"&gt;__call__&lt;/span&gt; was used for (which I actually like) and got used to the __'s (which I don't like) and I've never liked the self's in Python method arguments -- this made sense.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Function Returning a Function&lt;/span&gt;&lt;br /&gt;&lt;pre&gt;import re&lt;br /&gt;def searcher(rex):&lt;br /&gt;  crex = re.compile(rex)&lt;br /&gt;  def _(txt):&lt;br /&gt;     return crex.search(txt)&lt;br /&gt;  return _&lt;br /&gt;s = searcher("dog")&lt;br /&gt;print s("dog").string&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;At first this didn't make much sense and I got tricked by the underscore (thinking it was some sort of Perl-like special function name or something, it isn't though!). Wny would I call a function returning another function that I would use over and over again. Why would you do that? What is interesting though is if that s("dog")("dog") also produces identical results although I have no idea why (except that the first nested function within a function always executes the second parameter).&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/455416252368984615-5053437977004761374?l=happypython.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://happypython.blogspot.com/feeds/5053437977004761374/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=455416252368984615&amp;postID=5053437977004761374' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/455416252368984615/posts/default/5053437977004761374'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/455416252368984615/posts/default/5053437977004761374'/><link rel='alternate' type='text/html' href='http://happypython.blogspot.com/2007/12/obviously-im-not-even-intermediate.html' title='Obviously I&apos;m not Even an Intermediate Level Python Programmer'/><author><name>Matt Franz</name><uri>http://www.blogger.com/profile/00973881935128108475</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_MPIoEEC-IC0/SWXZy3zT_TI/AAAAAAAABHY/FmMm-co3m0Y/S220/blah.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-455416252368984615.post-3820504241696061290</id><published>2007-12-24T19:48:00.000-08:00</published><updated>2007-12-24T20:05:35.477-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Basics'/><title type='text'>Names, Objects, Bindings, and Thinking Like a Pythonista</title><content type='html'>On the Python Mailing list there was a discussion about "references" and someone posted a link to &lt;a href="http://starship.python.net/crew/mwh/hacks/objectthink.html"&gt;How to think like a Pythonista&lt;/a&gt; with some nice ASCII art.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;&lt;span style="font-family:courier new;"&gt;Names look like this:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;    ,-----.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;    | foo |&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;    `-----'&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;Names live in namespaces, but that's not really important for the&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;matter at hand as the only namespace in play is the one associated&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;with the read-eval-print loop of the interpreter.  In fact names are&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;only minor players in the current drama; bindings and objects are the&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;real stars.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;...&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;I haven't done much Ruby coding this month (cause of &lt;a href="http://blogfranz.blogspot.com/2007/12/welcome-samuel-austin.html"&gt;the baby&lt;/a&gt; so I'm trying to use the break to brush up on my Python. So a nice article for that.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/455416252368984615-3820504241696061290?l=happypython.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://happypython.blogspot.com/feeds/3820504241696061290/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=455416252368984615&amp;postID=3820504241696061290' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/455416252368984615/posts/default/3820504241696061290'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/455416252368984615/posts/default/3820504241696061290'/><link rel='alternate' type='text/html' href='http://happypython.blogspot.com/2007/12/names-objects-bindings-and-thinking.html' title='Names, Objects, Bindings, and Thinking Like a Pythonista'/><author><name>Matt Franz</name><uri>http://www.blogger.com/profile/00973881935128108475</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_MPIoEEC-IC0/SWXZy3zT_TI/AAAAAAAABHY/FmMm-co3m0Y/S220/blah.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-455416252368984615.post-2500532683798130753</id><published>2007-12-23T16:20:00.000-08:00</published><updated>2007-12-23T16:22:03.364-08:00</updated><title type='text'>Angry Ruby Meet Happy Python!</title><content type='html'>Because I don't seem &lt;a href="http://angryruby.blogspot.com"&gt;too angry&lt;/a&gt; anymore.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/455416252368984615-2500532683798130753?l=happypython.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://happypython.blogspot.com/feeds/2500532683798130753/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=455416252368984615&amp;postID=2500532683798130753' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/455416252368984615/posts/default/2500532683798130753'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/455416252368984615/posts/default/2500532683798130753'/><link rel='alternate' type='text/html' href='http://happypython.blogspot.com/2007/12/angry-ruby-meet-happy-python.html' title='Angry Ruby Meet Happy Python!'/><author><name>Matt Franz</name><uri>http://www.blogger.com/profile/00973881935128108475</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_MPIoEEC-IC0/SWXZy3zT_TI/AAAAAAAABHY/FmMm-co3m0Y/S220/blah.jpg'/></author><thr:total>0</thr:total></entry></feed>
